


























#编程技术 2019-10-29 16:46:00 | 全文 109 字,阅读约需 1 分钟 | 加载中... 次浏览
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>
×
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。