-4
rated 0 times
[
2]
[
6]
/ answers: 1 / hits: 89128
/ 12 Years ago, sat, may 12, 2012, 12:00:00
In a simple setInterval
setInterval(function() {
// Do something every 9 seconds
}, 9000);
The first action will happen after 9 seconds (t=9s
). How to force the loop to perform the first action immediately (t=0
)?
I think it is due to the mechanism of setInterval
to have Delay - Action - Delay - Action ...
loop; instead of Action - Delay - Action - Delay ...
loop.
EDIT: My function is indeed a loop as
setInterval(function(){
$('.test').each(function(idx){
var duration = 1000;
$(this).delay(duration*idx);
Some stuff here
});
}, 4000);
More From » jquery