jQuery 发送验证码倒计时按钮 复制代码

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script src="../scripts/jquery.js" type="text/javascript"></script>
    <script>
        $(function () {
            var util = {
                wait: 90,
                hsTime: function (that) {
                    _this = $(this);
                    if (_this.wait == 0) {
                        $('#hsbtn').removeAttr("disabled").val('重发短信验证码');
                        _this.wait = 90;
                    } else {
                        var _this = this;
                        $(that).attr("disabled", true).val('在' + _this.wait + '秒后点此重发');
                        _this.wait--;
                        setTimeout(function () {
                            _this.hsTime(that);
                        }, 1000)
                    }
                }
            }
            util.hsTime('#hsbtn');
            $("#hsbtn").click(function(){
                util.hsTime('#hsbtn');
            })
        })
    </script>
</head>
<body>
<input type="button" id="hsbtn" />
</body>
</html>

 

posted @ 2014-11-05 14:57  microsoftzhcn  阅读(7061)  评论(1编辑  收藏  举报