I am trying to build a series of nested timing loops. The inner loop iterates through 6 items with the same CSS class and swaps out an image for 4 seconds. The outer loop causes the inner loop to repeat continuously. So, image1 swaps, image2 swaps... image6 swaps, image1 swaps, image2 swaps... There are two images in each div, one with class 'hot' and one with class 'cold'. At the start, the 'hot' images are hidden.
The following code swaps all the images at once, after 24 seconds, and then doesn't seem to do anything else.
var innertime = 4000; //highlight effect time in ms
var outertime = innertime * 6;
setInterval(function() {
$.each($('.eachsponsor'), function(){
$(this).find('img.cold').css("display","none");
$(this).find('img.hot').css("display", "block");
setTimeout(function(){
$(this).find('img.hot').css("display","none");
$(this).find('img.cold').css("display", "block");
}, innertime);
});
}, outertime);
If anybody has any pointers on why this doesn't work, I'd sure appreciate it.