发送验证码倒计时js

//发送短信验证码
var sendCode=function(id){
var time=120;
$(id).attr('disabled', 'true').addClass('sending disabled');
config.timer=setInterval(function(){
time--;
$(id).html("重新发送("+time+")");
if(time==0){
$(id).removeAttr('disabled').removeClass('sending disabled');
$(id).html("获取验证码");
time=120;
clearInterval(config.timer);
}

}, 1000);
return false;
}

原文地址:https://www.cnblogs.com/sure2016/p/7413590.html