js限制button十秒内不能重复点击
<html>
<body>
<input type="button" value="按钮" id="btn"/>
</body>
<script>
var wait = 10;
document.getElementById("btn").onclick = function() {
time(this);
alert("十秒后解除点击限制!");
}
function time(o) {
if (wait == 0) {
o.removeAttribute("disabled");
wait = 10;
} else {
o.setAttribute("disabled", true);
wait--;
setTimeout(function() {
time(o)
}, 1000)
}
}
</script>
</html>