jquery 60秒倒计时(方法二)

时间:2024-04-17 22:11:36

<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)
}
}
document.getElementById("btn").onclick=function(){time(this);}
</script>

 

 


<input type="submit" value="获取验证码" name="agreeb" id="btn">