zoukankan      html  css  js  c++  java
  • 设置倒计时10秒可用的按钮JS函数(转)

    方式一:

    <input value="同 意" type="submit" name="rulesubmit" />
    <script>
        var secs = 9;  
       var wait = secs * 1000;
       document.bbrules.rulesubmit.value = "同 意(" + secs + ")";
       document.bbrules.rulesubmit.disabled = true;
        function update(num) {
                 if(num == (wait/1000)) {
           document.bbrules.rulesubmit.value = "同 意";} 
           else {
           var printnr = (wait / 1000) - num;
           document.bbrules.rulesubmit.value = "同 意(" + printnr + ")";}
           }
       function timer() {
           document.bbrules.rulesubmit.disabled = false;
           document.bbrules.rulesubmit.value = "同 意";}    
       for(i = 1; i<= secs; i++) {
       window.setTimeout("update(" + i + ")",i * 1000);
         }
       window.setTimeout("timer()", wait);  
      
       </script>

    方式二:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>按钮倒计时</title>

    </head>

    <body>
    <p>
    <label><input   type="submit"   name="btnSubmit"   id="btnSubmit"   value="提交"   />  
    </label>
    </p>

    </body>
    <script language="javascript">

    var n = 10;//计数器  
    //document.all.btnSubmit.disabled = true;
        document.getElementById("btnSubmit").disabled = true;
    function btnShow()  
    {  
       str = "倒计时...";  
       n--;
       if(n <=   0)  
       {  
        document.getElementById("btnSubmit").value = "提交";  
        document.getElementById("btnSubmit").disabled = false;  
       }  
       else  
       {  
        document.getElementById("btnSubmit").value = str + n +"秒";
       }  
    }
        window.setInterval(btnShow,1000);  

    </script>
    </html>


  • 相关阅读:
    NTP服务器搭建
    Linux安装MongoDB 4.4.2
    CentOS安装Zookeeper 3.6.2
    CentOS安装Redis 6.0.9
    MacBook Home End
    SLES Install
    cucumber soapui test web services
    S/4 HANA Solution Manager
    Linux下创建新用户
    su with hyphen and without
  • 原文地址:https://www.cnblogs.com/Godblessyou/p/1934353.html
Copyright © 2011-2022 走看看