JavaScript实现短信倒计时60s

废话不多说了,直接给大家贴代码了,具体代码如下所示;

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

总结

以上所述是小编给大家介绍的JavaScript实现短信倒计时60s,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: