按钮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);
})

 

posted @ 2016-12-16 09:13  幸福的目标  阅读(240)  评论(0编辑  收藏  举报