日期:2014-05-16 浏览次数:20473 次
//闪电timer
function startLightning(){
timer1 = setInterval('lightToGray()', 4920);
timer2 = setInterval('lightToChange()', 5000);
//clearTimeout(timer1);
//clearInterval(timer2);
}
//闪电变灰
function lightToGray(){
//随机获取div的行列数,以随机选择div进行变色
randomR = Math.floor(Math.random()*maxR);
randomC = Math.floor(Math.random()*maxC);
beforeColor = document.getElementById("r"+randomR+"c"+randomC).style.backgroundColor;
document.getElementById("r"+randomR+"c"+randomC).style.backgroundColor = "dimgray";
}
//闪电变色
function lightToChange(){
if(beforeColor == "blue"||beforeColor == "yellow"||beforeColor == "red"||beforeColor == "black"){
document.getElementById("r"+randomR+"c"+randomC).style.backgroundColor = beforeColor;
}
else{
document.getElementById("r"+randomR+"c"+randomC).style.backgroundColor = "yellow";
}
}
var flag=true;
//闪电timer
function startLightning(){
timer1 = setInterval(function(){
if(flag)
{
lightToGray();
}else{
lightToChange()
}
flag=!flag;
}, 800);
}
function startLightning(){
timer1 = setTimeout('lightToGray()', 4920);
timer2 = setTimeout('lightToChange()', 5000);
//clearTimeout(timer1);
//clearInterval(timer2);
}
//闪电变灰
function lightToGray(){
//随机获取div的行列数,以随机选择div进行变色
randomR = Math.floor(Math.random()*maxR);