<!DOCTYPE html>
<html>
<head>
  <title>60秒倒计时</title>
  <script type="text/javascript">
    window.onload=function(){
      var oBtn = document.getElementById('but');
      var conut = 60;
      var timer = null;
      oBtn.onclick=function(){
        timer=setInterval(function(){
          settime()
        },1000)
      }
      function settime(){
        if(conut == 0){
          oBtn.value = '免费获取验证码';
          oBtn.removeAttribute("disabled");
          clearInterval(timer);
          conut=60;
        }else{
          conut --;
          oBtn.value = conut +'后可以重发';
          oBtn.setAttribute("disabled", true); 
        }
      }
    }
  </script>
</head>
<body>
  <input type="button" value="免费获取验证码" id="but">
</body>
</html>

 

posted on 2015-05-04 16:06  高尔础础  阅读(308)  评论(0编辑  收藏  举报