标签:NPU remove disabled ext att 最简 计时 script set
百度了很多,找到了一个最简单的代码
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js点击按钮后,倒计时N秒后才能再次点击提交</title>
</head>
<body>
<input type="button" id="btn" value="免费获取验证码" />
<script type="text/javascript">
var wait = 60;
function time(obj) {
if (wait == 0) {
obj.removeAttribute("disabled");
obj.value = "免费获取验证码";
wait = 60;
} else {
obj.setAttribute("disabled", true);
obj.value = "重新发送(" + wait + ")";
wait--;
setTimeout(function () {
time(obj)
},
1000)
}
}
document.getElementById("btn-form1").onclick = function () { time(this); }
</script>
</body>
</html>
标签:NPU remove disabled ext att 最简 计时 script set
原文地址:https://www.cnblogs.com/cn-oldboy/p/13227806.html