function autochange(){ times--; if(times==0){
send.value="发送验证码";
send.style.color="black";
clearInterval(timer); send.disabled=false;
}else{send.value=times+"秒后重试"; } } } }
send.value="发送验证码";
send.style.color="black";
clearInterval(timer); send.disabled=false;
}else{send.value=times+"秒后重试"; } } } }
<script type="text/javascript">
window.onload=function(){
var send=document.getElementById("send");
timer=null;
send.onclick=function(){
times=60;
send.disabled=true;
send.style.color="#aaa";
send.value=times+"秒后重试";
window.onload=function(){
var send=document.getElementById("send");
timer=null;
send.onclick=function(){
times=60;
send.disabled=true;
send.style.color="#aaa";
send.value=times+"秒后重试";
// 鼠标划过整个容器时停止自动播放
for(var i=0;i<lis.length;i++){
lis[i].onmouseover = function(){
clearInterval(timer);
}
// 鼠标离开整个容器时继续播放至下一张
lis[i].onmouseout = function(){
timer = setInterval(changeOption,1000);
}
}
for(var i=0;i<lis.length;i++){
lis[i].onmouseover = function(){
clearInterval(timer);
}
// 鼠标离开整个容器时继续播放至下一张
lis[i].onmouseout = function(){
timer = setInterval(changeOption,1000);
}
}
2017-04-05
timer = setInterval(changeOption,1000);
// 定义图片切换函数
function changeOption(){
list[index].className ="";
index++;
if(index>=lis.length){
index = 0;
}
pic.style.top = -170*index+"px";
list[index].className ="on";
}
// 定义图片切换函数
function changeOption(){
list[index].className ="";
index++;
if(index>=lis.length){
index = 0;
}
pic.style.top = -170*index+"px";
list[index].className ="on";
}
2017-04-05
超级棒的
timer = setInterval(function(){
list[index].className ="";
index++;
if(index>=lis.length){
index = 0;
}
pic.style.top = -170*index+"px";
list[index].className ="on";
},1000);
timer = setInterval(function(){
list[index].className ="";
index++;
if(index>=lis.length){
index = 0;
}
pic.style.top = -170*index+"px";
list[index].className ="on";
},1000);
2017-04-05
timer = setInterval(function(){
index++;
if(index>=lis.length){
index = 0;
}
pic.style.top = -170*index+"px";
},1000);
index++;
if(index>=lis.length){
index = 0;
}
pic.style.top = -170*index+"px";
},1000);
2017-04-05
已采纳回答 / 薛定谔的量子猫
因为timer接收到的是setTimeout返回的一个整数类型的值,clearTimeout()是根据这个值去清除计时器,计时器清除后timer变量的值依旧不变,所以最好重新赋值为NULL;setInterval也是同样道理
2017-04-03