js实现验证码倒计时效果

Html

<button class="getCode">获取验证码</button>

js

  var wait=60;
    function time(o){
        if (wait==0) {
            o.removeAttribute("disabled");    
            o.innerHTML="输入验证码";
            o.style.backgroundColor="#fe9900";
            wait=60;
        }else{
            o.setAttribute("disabled", true);
            o.innerHTML=wait+"秒后重新获取";
            o.style.backgroundColor="#8f8b8b";
            wait--;
            setTimeout(function(){
                time(o)
            },1000)
        }
    }
   $(".getCode").click(function(){
        time(this);
    });
发布了7 篇原创文章 · 获赞 5 · 访问量 309

猜你喜欢

转载自blog.csdn.net/weixin_44064357/article/details/104506098