<pre name="code" class="html">var disabled = true;
function on_msg_click() {
var wattingSecond = 60; //倒计时时间60秒
var verificationCodeInterval;
if (disabled == false) {
return;
}
if (verificationCodeInterval) {
clearInterval(verificationCodeInterval);
}
verificationCodeInterval = setInterval(function () {
if (wattingSecond <= 0) {
clearInterval(verificationCodeInterval);
$(".codebtn").text("发送验证码"); //按钮文字
disabled = true;
return;
}
else {
$(".codebtn").text(wattingSecond + " 秒"); //按钮内容转为倒计时
wattingSecond--;
disabled = false;
}
}, 1000);
}
验证码倒计时代码
最新推荐文章于 2020-01-07 15:52:01 发布