I have something like the following code
for(i=0, j=10; i<j ; i++){
$('#an-element-'+i).fadeIn();
}
How do I make it so that each iteration in the loop will only start once the fadeIn(); animation has completed?
edit---sorry my bad I had not included the 'i' in the loop
According to your code, your loop will just fade in the same element 10 times.
In any case, what you need is to put the call in the callback of the fadein method : http://api.jquery.com/fadeIn/
Something like this should work (not tested)
Try this:
You can change the time duration inside the delay function. Here is the jsFiddle.
if you have a fixed delay for all the item you may use this line of code:
instead of
for
loops are synchronous, but animations are asynchronous. You'll need to use recursion.http://jsfiddle.net/uq9mH/
You can execute code after an animation by placing it in a function passed as the callback parameter:
But it is not quite clear what you're trying to do. Are you fading the same element 10 times?