js 倒计时10s

时间:2023-03-09 04:25:37
js 倒计时10s
<button id="send">允许点击</button>
var wait = 10;
function time(o){
if(wait==0){
o.innerHTML = "允许点击";
o.removeAttribute('disabled',true);
wait = 10
}else{
o.innerHTML = "无法点击"+wait;
console.log(wait)
o.setAttribute('disabled',true);
  wait--;
setTimeout(function(){
time(o)
},1000)
}
}
document.getElementById('send').onclick = function(){
time(this)
}