问答详情
源自:3-4 编程练习

代码只执行一次,再点击就没用了

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
window.onload=function(){
   var send=document.getElementById('send'),
       times=60;
       timer=null;
   send.onclick=function(){
     timer=setInterval(function(){ 
            times--
            send.value=times+"秒后重试" 
            send.disabled=true
             
          if(times<=50){  
              clearInterval(timer);
              send.disabled=false
              send.value="发送验证码";
            } 
    },1000);
 
}
}
</script>
</head>
<body>
<input type="button" id="send" value="发送验证码">
</body>
</html>


提问者:qq_小白_7 2015-09-25 12:14

个回答

  • Kusoku
    2015-09-25 15:12:07
    已采纳

    times忘了重置