How to do this trick with jquery each?
My php code is:
for($i = 1; $i < 22; $i++) {
echo '<div id="number" style="display:none">'.$i.'</div>';
}
My jquery code:
$('#number').each(function() {
$(this).slideDown("slow");
})
What is wrong here? I want to achieve the effect when all the numbers appear, one after another. I mean, first of all, slides down number 1, after it number 2 and so on. And now only slide down number 1, and nothing happens after it, although I use jquery each. Thank.
Firstly, your PHP needs to be changed, it displays invalid HTML, so this:
for($i = 1; $i < 22; $i++) {
echo '<div id="number" style="display:none">'.$i.'</div>';
}
You need to be something like this (or remove it idcompletely if it is not needed):
for($i = 1; $i < 22; $i++) {
echo '<div id="number'.$i.'" class="number" style="display:none">'.$i.'</div>';
}
Then your jQuery should look something like this:
$('.number').each(function(i) {
$(this).delay(600*i).slideDown("slow");
});
, 600 ( "" = 600 ), 1200 .., . , , .delay() , .