Ok, Simply... I want to make this (which works perfectly, but is obviously too much writings when i have #b up to #b20):
$("#b" + 1).click(function () {
$('.c').hide();
$(".a" + 1).show();
});
$("#b" + 2).click(function () {
$('.c').hide();
$(".a" + 1).show();
});
Simple, like this:
for (var i = 0; i < 50; i += 1) {
$("#b" + i).click(function () {
$('.c').hide();
$(".a" + i).show();
alert('Hey'+i);
});
}
$("#b" + i) is button on htmlpage, and $(".a" + i) is the text which is supposed to be viewed on the page by clicking on the button. //So the text is with class="c a1", class="c a2", ...; and the button is with id="#b1", id="#b2"... But when I execute the code (Click on #b1, #b2, or...), .c hides (as expected), and the next step is only executed for i=50 (proved with the alert).
Any ideas?