• 点击发送验证码倒计时


    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
    <input type="text"/>
    <button id="btn">点击发送短信</button>
    </body>
    </html>
    <script>
        var btn = document.getElementById("btn");
        var count = 5;  // 数据的 10
        var timer = null; // 定时器的名字
        btn.onclick = function() {
            clearInterval(timer);  // 先清除掉原来的定时器
            // alert(11);
            this.disabled = true;
             //alert(this);  // this 指向的是 btn
            var that = this;  // 把 btn 对象 给 that  var _this = this;
            timer = setInterval(sendTextMessage,1000);  // 开启定时器 名字  timer
            function sendTextMessage() {
                count--;
            //this.innerHTML = "还剩余"+count+"秒";
               // alert(this); // this 指向的是 定时器  window
                //alert(that);
                if(count >= 0 )
                {
                    that.innerHTML =  "还剩余"+count+"秒";
                }
                else
                {
                    that.innerHTML = "重新发送短信";
                    that.disabled = false;
                    clearInterval(timer);  // 清除定时器
                    count = 5;
                }


            }

        }
    </script>

  • 相关阅读:
    Centos7 FTP服务安装,Centos FTP安装配置
    Shiro CookieRememberMeManager Invalid AES key length
    Shiro thymeleaf整合使用
    闪存中的键值对:无文件系统 minINI
    SAP UI类标准导出XML格式Excel
    CRM item status error
    被某个自认漂亮国的狗腿子骂了。。。
    New ABAP Debugger Session does not close after Exit
    Java队列使用举例
    布隆过滤器使用举例
  • 原文地址:https://www.cnblogs.com/fdxxiaobai/p/7642449.html
Copyright © 2020-2023  润新知