제한 시간이있는 텍스트의 색을 변경하려고합니다. 매 5 초마다 색상이 변경되어야합니다. 방금 작동하지 않습니다. 내가 도대체 뭘 잘못하고있는 겁니까?지연 텍스트 색 전환
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;
}
}
전체 예 : http://jsfiddle.net/xLS25/
감사를 시도하고 :) – VRC
아무 문제입니다. 그건 그렇고, 배열을 리터럴로 선언하고 싶지 않은 이유가 있습니까? (내 대답은 P.S.를 참조하십시오) –