真的是老了,写个js的计时器居然用了20分钟,惭愧
/*计时器*/
var wait = 60;
var e=document.getElementById("btn");
e.onclick = function() {
time(this);
}
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)}
}
网友评论