Javascript / jQuery flick between two images
I'm struggling with the timer part. I can replace one image开发者_StackOverflow with another easily with javascript by calling the function. What I want to be able to do is set a timer to sit and change the images at a specific interval (say 1 second).
I've used jQuery to refresh an image every second before, but when I try and add a function inside to change the image, it just hangs.
you can use setinterval function of javascript:
setInterval(function,time); //ex: setInterval(myfunction,1000)
setInterval will also return a pointer to time which can be used later on to clearInterval
var interval = setInterval(myfunction,1000);
later you can use:
clearInterval(interval)
精彩评论