var wait = 5;
document.getElementById("btn").onclick = function() {
time(this);
}
function time(o) {
if (wait == 0) {
o.removeAttribute("disabled");
wait = 5;
} else {
o.setAttribute("disabled", true);
wait--;
setTimeout(function() {
time(o)
}, 1000)
}
---------------------
作者:xhyzkk
来源:CSDN
原文:https://blog.csdn.net/xhyzkk/article/details/74177727
版权声明:本文为博主原创文章,转载请附上博文链接!