jquery 获取验证码倒计时

<button type="button" class="mui-btn mui-btn-primary mui-btn-outlined mui-pull-right" id="yanzm">获取验证码</button>


$("#yanzm").on('click',function(){
var num=60;
this.disabled=true;
var self=this

var time=setInterval(function(){
if(num>=0){
$(self).text("发送验证码("+num+")s");
num--
}else{
$(self).text("重新发送");
clearInter(time);
self.disabled=false;
}

},1000)
})

posted @ 2017-05-08 11:19  yaomengli  阅读(295)  评论(0编辑  收藏  举报