Home > Article > Web Front-end > Use JS to resend the verification code after 60 seconds
This time I will bring you the function of using JS to resend the verification code after 60 seconds. NotesWhat are they? Here are actual cases. Let’s take a look. //settime($("#getPhoneCode"),60);
function settime($obj, time) {
if (time == 0) {
$obj.attr("disabled", false);
$obj.css("background", "#f38401").css("cursor", "pointer");
$obj.text("获取手机验证码");
return;
} else {
$obj.attr("disabled", true);
$obj.css("background", "#ccc").css("cursor", "not-allowed");
$obj.text("重新发送(" + time + ")");
time--;
}
setTimeout(function () { settime($obj, time) }, 1000)
}
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
angular2 nodejs to make image upload effectJS array deduplication image and text detailed explanationJS string traversal, interception, output, calculation operations
The above is the detailed content of Use JS to resend the verification code after 60 seconds. For more information, please follow other related articles on the PHP Chinese website!