获取验证码

获取验证码倒计时:

<!DOCTYPE html>
<html>
<head>
    <title>获取验证码倒计时</title>
</head>
<body>
<input id="btn"  value="获取验证码" onclick="time(this);">
<script type="text/javascript">
    var wait = 60;
    document.getElementById("btn").disabled = false;
    function time(o) {
        if (wait == 0) {
            o.removeAttribute("disabled");
            o.value = "获取验证码";
            wait = 60;
        } else {
            o.setAttribute("disabled", true);
            o.value = "重新发送(" + wait + ")";
            wait--;
            setTimeout(function() {
                        time(o);
                    },
                    1000);
        }
    }
</script>
</body>
</html>

 

posted @ 2017-02-10 13:34  最爱小虾  阅读(250)  评论(0编辑  收藏  举报