JS button is not available within a few seconds after clicking, and the button countdown is disabled

From , 5 Years ago, written in JavaScript, viewed 232 times.
URL https://pastebin.vip/view/ecdcd675
  1. function timer(time) {
  2.         var btn = $("#sendButton");
  3.         btn.attr("disabled", true);  //按钮禁止点击
  4.         btn.val(time <= 0 ? "发送动态密码" : ("" + (time) + "秒后可发送"));
  5.         var hander = setInterval(function() {
  6.                 if (time <= 0) {
  7.                         clearInterval(hander); //清除倒计时
  8.                         btn.val("发送动态密码");
  9.                         btn.attr("disabled", false);
  10.                         return false;
  11.                 }else {
  12.                         btn.val("" + (time--) + "秒后可发送");
  13.                 }
  14.         }, 1000);
  15. }
  16.  
  17.  
  18. //调用方法
  19. timer(30);
  20.  

Reply to "JS button is not available within a few seconds after clicking, and the button countdown is disabled"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website