首先写一个按钮:

<input type="button" id="btn" value="免费获取验证码" onclick="time(this)" />

然后写js代码:

var wait=60;
    function time(o){
        if (wait==0) {
            o.innerHTML="重新发送验证码";
            o.style.backgroundColor="#388BE8";
            o.removeAttribute("disabled");
            wait=60;
        }else{
            o.setAttribute("disabled", true);
            o.innerHTML=wait+"秒后重新获取";
            o.style.backgroundColor="#8f8b8b";
            wait--;
            setTimeout(function(){
                time(o)
            },1000)
        }
        
    }

欢迎关注微信公众号:lovephp

js 发送验证码倒计时

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-09
  • 2021-12-21
猜你喜欢
  • 2021-11-25
  • 2021-12-25
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
相关资源
相似解决方案