Any idea why this code is broken or not working? It is not my code but it does appear to be correct, of course I could be missing the obvious. I simply need the background image of a div to cycle to a new one in the/a array ever 5 seconds.
var imageIndex = 0; var imagesArray = new Array(); //Set Images imagesArray[0] = "images/self-whitewater.png"; imagesArray[1] = "images/fishing.png"; imagesArray[2] = "images/solo-kayaking.png"; function changeBackground(){ $("main-blocki").css("background","url('"+ imagesArray[imageIndex] +"')"); imageIndex++; if (imageIndex > imageArray.length) imageIndex = 0; } $(document).ready(function() { setInterval("changeBackground()",5000); });