点击获取验证码按钮后按钮变灰,倒计时一段时间后又可重复点击
html中:js中:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var wait=60;
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_x_x_x_x_x_x_x("btn").onclick=function(){time(this);}
页:
[1]