Javascript 实现 点击按钮 倒计时60秒方可再次点击发送的效果
Document 获取短信验证码
Javascript代码:
var countDownT = 60;
function get_sms_captcha(type){
countDownT = 60;
setTime();
//下方写业务
}
function setTime(){
if (countDownT == 0){
$("#gSMS").attr("onclick","get_sms_captcha('2')");
$("#gSMS").text("获取短信验证码");
} else{
$("#gSMS").attr("onclick","#");
$("#gSMS").text("重新发送("+countDownT+")");
countDownT--;
setTimeout(function () {
setTime();
},1000)
}
}效果图:
