jQuery 60s倒计时

<input id="code" type="button" value="发送验证码" />

<script>
    var obj = $('#code');
    obj.on('click', function () {
        var count = 6;
        var timer = setInterval(function () {
            obj.attr('disabled', true);
            obj.val(count);
            count--;
            if (count < 0) {
                clearInterval(timer);
                obj.val('发送验证码');
                obj.attr('disabled', false);
            }
        }, 1000);
    })
</script>

 

posted @ 2018-06-15 18:26  清风晰心  阅读(130)  评论(0编辑  收藏  举报