首页 > 代码库 > js 倒计时10s

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)
            }

 

js 倒计时10s