How do I call a given function every X seconds ? In this case i made a function that scrolls some images . I want the image to change based on a given interval of time ex every 5 seconds but i really have no idea :/ some suggestions and good practice for this ? Thank you.
+2
A:
No need for jQuery here, plain JavaScript using setInterval()
will do:
function myFunctionName() {
//change image here
}
setInterval(myFunctionName, 5000);
Or the anonymous version:
setInterval(function () {
//change image here
}, 5000);
Nick Craver
2010-10-26 20:29:03
A:
If you want jquery to do it for you, there is a plugin jquery.cycle.all. This will make creating the transition very easy. If you're using jquery already, then it might be a good fit. Otherwise, the setInterval is easy to work with that other posters already mentioned.
Edit: found the plugin to link to:
Kevin Nelson
2010-10-26 20:34:16