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)
}
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!