JQuery实现定时阅读协议按扭(每秒执行一次)

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta charset="utf-8" />
    <script src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        var sec = 4;
        $(function () {
            var settime = setInterval(function () {
                if (sec > 0) {
                    $('#btn1').val('请仔细阅读协议(' + sec + ')');
                    sec--;
                } else {
                    $('#btn1').val('同意').prop('disabled', false);
                    clearInterval(settime);
                }
            }, 1000);
        });
    </script>
</head>
<body>
    <input type="button" value="请仔细阅读协议(5)" id="btn1" disabled="disabled" />
</body>
</html>

评论