I'm trying to change the color of the text with a timeout. like every 5 seconds the colors should change. I just can't get it to work. What am I doing wrong?
var rainBowColors = new Array();
rainBowColors.push("#FF0000"); //Red: #FF0000
rainBowColors.push("#FF7F00"); //Orange: #FF7F00
rainBowColors.push("#FFFF00"); //Yellow: #FFFF00
rainBowColors.push("#00FF00"); //Green: #00FF00
rainBowColors.push("#0000FF"); //Blue: #0000FF
rainBowColors.push("#4B0082"); //Indigo: #4B0082
rainBowColors.push("#8F00FF"); //Violet: #8F00FF
var rainbowCounter = 0;
for (var counter = 0; counter < 1000; counter++)
{
//Easter :)
//var timeOut = setTimeOut(function(){
jQuery(".text").css("color", rainBowColors[rainbowCounter]);
//}, 500);
//clearTimeOut(timeOut);
//Higher Counter
rainbowCounter++;
//Reset counter
if (rainbowCounter == rainBowColors.length)
{
rainbowCounter = 0;
}
}
Full example : http://jsfiddle.net/xLS25/