验证码倒计时60秒

<script src="../../public/jquery.js"></script>
<h4>验证码</h4>
<div class="regin_yan_bac">
   <input type="password">
   <button class="sms_click">发送验证码</button>
</div>

<script>
   //获取验证码
   var wait = 60;
   function countdown(timeer) {
     var $timeer = $(timeer)
     if (wait == 0) {
       $timeer.attr("disabled", false);
       $timeer.html("发送验证码")
       wait = 60;
     } else {
       $timeer.attr("disabled", true);
       $timeer.html(+wait + "秒后获取");
       wait--;
       setTimeout(function () {
          countdown(timeer)
       }, 1000);
   }
}

$(".sms_click").on("click", function () {
   countdown(this);
})
</script>
原文地址:https://www.cnblogs.com/zpblogs/p/10076482.html