$('.box').each(function(i){ // 'i' = index var spd = 700; // set speed (animation/delay) time var dly = spd*i; // 700*0 = 0 ; 700*1 = 700 ..... $(this).delay(dly).animate({width: 500 },spd); // now you have proper delays. });
EDIT: $('.box').each(function(i){ var dly = 400*i;
And all in a few lines.
It is unbelievable that the above was “-1” after Q to change 1h after my first answer.
Never mind. A few lines here is your script.
By the way, the above was so nicely explained that someone can fix it in seconds to get the best results. The approach was key. Thank you !;)
source share