Home > Web Front-end > JS Tutorial > body text

How to implement 60s countdown for text messages

小云云
Release: 2018-01-26 16:48:38
Original
2061 people have browsed it

This article mainly shares with you a piece of example code to give you a detailed introduction to JavaScript to implement the SMS countdown 60s function. It is very good and has reference value. Friends who need it can refer to it. I hope it can help everyone.

Without further ado, I will post the code directly for you. The specific code is as follows;


##

$(function(){
   //获取验证码
   var getCode = document.getElementById('getCode');
    var wait = 60;
    function time(btn){
      if (wait===0) {
        btn.removeAttribute("disabled");
        btn.innerHTML = "获取验证码";
        wait = 60;
      }else{
        btn.setAttribute("disabled",true);
        btn.innerHTML = wait + "秒后重试";
        wait--;
        setTimeout(function(){
          time(btn);
        },1000);
      }
    }
    getCode.onclick = function(){
      time(this);
    };
})
Copy after login

Related recommendations:


Instance analysis of 60s countdown for obtaining verification code in WeChat applet

js anti-refresh countdown code js countdown code

How to implement jQuery page countdown and refresh effects


The above is the detailed content of How to implement 60s countdown for text messages. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!