Monday, 9 September 2013

jQuery animate each element but with a delay between each one

jQuery animate each element but with a delay between each one

With the following Im fading in and out a div on a loop that lasts forever.
function fadeOutFunc() {
$('.image-list
.bottom').delay(5000).fadeOut(500).delay(5000).fadeIn(500,fadeOutFunc);
}
fadeOutFunc();
This is working fine but I need to change it a a bit. I have 4 divs that
the selector targets. I want the first one to start animating after 5
seconds as it currently does. However I want the 2nd div to start
animating after 6 seconds, the third div after 7 seconds, and the 4th div
after 8 seconds.
The most scalable code would be one that would work even if there were
more than 4 divs that matched the selector.

No comments:

Post a Comment