手机校验码倒计时

来源:互联网 发布:渠道网络 编辑:程序博客网 时间:2024/06/07 00:29
<html>    <head>        <title></title>        <meta charset="UTF-8">        <meta name="viewport" content="width=device-width, initial-scale=1.0">        <script src="jquery.min.js"></script>               <script>        $(function () {            var code = {                wait: 5,                hsTime: function (that) {                    _this = $(this);                    var _this = this;                    $(that).attr("disabled", true).val(+ _this.wait + '秒后重新获取');                                        if (_this.wait == 0) {                        $('#btn').attr("disabled", false).val('点击获取校验码');                        _this.wait = 5;                        return;                    }                     _this.wait--;                    setTimeout(function () {                        _this.hsTime(that);                    }, 1000)                }                            }            code.hsTime('#btn');            $("#btn").click(function(){                code.hsTime('#btn');            })        })                  </script>    </head>    <body>                <input type="button" id="btn" value=""/></body></html>

0 0
原创粉丝点击