Fiddle here:
http://jsfiddle.net/F6nJu/
I have a colored box:
<div id="colorblock"></div>
#colorblock { background:#3ff; width: 100%; height: 300px; }
I have an array of colors created in javascript:
var arr = [ "#f00", "#ff0", "#f0f", "#f66"];
I iterate through those colors with a jQuery each() function:
$.each(arr, function(key, value) {
$('#colorblock').delay('1200').animate({backgroundColor:value}, 600);
});
When the array iterates to the end, how can I start the array iteration over (so the animation goes on forever)?
Infinite recursion. Delete the current entry, then add the current value to the end.
Live ExampleFor those who are interested in what the array looks like: