js 倒计时10s

Posted freddyhuang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章