Home  >  Article  >  Web Front-end  >  Use JS to resend the verification code after 60 seconds

Use JS to resend the verification code after 60 seconds

php中世界最好的语言
php中世界最好的语言Original
2018-04-19 13:52:312902browse

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 effect


JS array deduplication image and text detailed explanation


JS 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn