其他分享
首页 > 其他分享> > js获取验证码倒计时

js获取验证码倒计时

作者:互联网

<button type="button" id='getting' onclick="time(this)" class="mui-btn text-primary" style="height: 40px;width:30%;">获取验证码</button>

 //倒计时
 var wait = 60;
 function time(btnObj) {
     if(wait == 0) {
         btnObj.removeAttribute("disabled");
         btnObj.textContent = "重新发送";
         wait = 60;
     } else {
         btnObj.setAttribute("disabled", true);
         btnObj.textContent = wait + "秒";
         wait--;
         setTimeout(function() {
             time(btnObj)
         }, 1000)
     }
 }

 

标签:function,60,btnObj,textContent,验证码,js,倒计时,disabled,wait
来源: https://www.cnblogs.com/yydxh/p/15133125.html