zoukankan      html  css  js  c++  java
  • js 计时器

    <html>
    <header></header>
    <script>
    
        var wait=60;
        var interValObj; 
        function fsend(){
        interValObj = window.setInterval(setRemainTime, 1000); ///--启动计时器,1秒执行一次   
     
        document.getElementById("code_button").disabled=true;
        document.getElementById("code_button").innerText="倒计时 " + wait + "";
     
       }
       
       function setRemainTime() {  
            if (wait == 0) {                  
                window.clearInterval(interValObj); //停止计时器            
               document.getElementById("code_button").disabled=false;
               document.getElementById("code_button").innerText="重新发送验证码" ;
               document.getElementById('code_value').value = '';  //清除验证码。如果不清除,过时间后,输入收到的验证码依然有效      
                wait = 60;
            }  
            else {  
                wait--;  
                document.getElementById("code_button").innerText="倒计时 " + wait + "";             
            }  
        } 
    </script>
    <body>
       Send Scode  <input type="text" id="code_value"/>  
       <button type="button" id="code_button" name="send"   onclick="fsend()"   >发送验证码</button>
      
    </body>
    
    </html>
  • 相关阅读:
    【leetcode】1230.Toss Strange Coins
    2018.12.25 SOW
    L203 词汇题
    L202
    L201
    L200
    2018
    2018.12.21 Cmos- RF
    L198
    L196 Hospital educations
  • 原文地址:https://www.cnblogs.com/rojas/p/9227782.html
Copyright © 2011-2022 走看看