Javascript: Using setInterval() in conjunction with looping through an array?

Question by jayztttight: Javascript: Using setInterval() in conjunction with looping through an array?
Ok so this might potentially be a tough question, keep that in mind. All the effects I explain will be accomplished using jQuery, I only need advice regarding the actual logic.

Ok so basically I have a collection of pictures (which I will be storing in an array), let’s say 5.

Every 12 seconds, I want to fade out the current image, and fade the next one in the array in. If it gets to the very last picture, I want it to go back to the first picture. This needs to be done endlessly. Someone suggested I used setInterval() for this, but I have no idea how to go about this. Any suggestions at all?

Best answer:

Answer by Jeff E
I was just messing around with a crossfade slideshow script yesterday. I used the setTimeout in it and it will loop continuously. Just place this script in the head and call the runSlideShow() with body onload, and give the img tag you want it to appear in an id of “adBanner” or change that in the script to your own id.



Ad Banner


Give your answer to this question below!

About Admin