zoukankan      html  css  js  c++  java
  • 点击发送短信剩余秒数

    <!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>

  • 相关阅读:
    Leo程序员羊皮卷文摘(更新ing)
    ubuntu下的yuv播放器
    浏览器之一
    海量数据处理常用思路和方法(zh)
    我本将心向明月,奈何明月照沟渠
    转载光纤通信之父
    重装系统或是更换电脑之后,Foxmail的恢复
    关于录制Linux视频
    Linux之路(原发表于07年,现在搬到博客)
    Gentoo安装 miniCD+stage3
  • 原文地址:https://www.cnblogs.com/xiaomifeng/p/6792114.html
Copyright © 2011-2022 走看看