Home  >  Article  >  Web Front-end  >  js text message countdown to 60 seconds method

js text message countdown to 60 seconds method

一个新手
一个新手Original
2017-10-09 09:50:421147browse


$(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);
        };
})

The above is the detailed content of js text message countdown to 60 seconds method. 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