<head>
<title>jquery点击按钮后灰色倒计时并且无法提交,倒计时结束后恢复</title>
<script type=”text/javascript” src=”http://www.198zone.com/statics/js/jquery.min.js”></script>
<script type=”text/javascript”>
$(function () {
$(‘#btn’).click(function () {
var count = 10;
var countdown = setInterval(CountDown, 1000);
function CountDown() {
$(“#btn”).attr(“disabled”, true);
$(“#btn”).val(“您在” + count + ” 秒后可以再次获取!”);
if (count == 0) {
$(“#btn”).val(“重新获取验证码”).removeAttr(“disabled”);
clearInterval(countdown);
}
count–;
}
})
});
</script>
</head>
<body>
<input type=”button” id=”btn” value=”提交” />
</body>

Tagged with: