首页 > 代码库 > 按钮60秒倒计时

按钮60秒倒计时

var wait = 60;
function timeDown(obj){
    if( wait === 0 ){
        obj.removeAttribute(‘disabled‘);
        obj.value = "获取验证码";
        wait = 60;
    }else{
        obj.setAttribute(‘disabled‘,true);
        obj.value="重新发送" + wait +"";
        wait--;
        setTimeout(function(){
            timeDown(obj)
        },1000)
    }
}
$(‘.btnCode‘).on(‘click‘,function(){
    timeDown(this);
})

 

按钮60秒倒计时