点击获取验证码倒计时

<input type="button" class="btn c-333 text-c js-code" value="获取验证码" onclick="settime(this);" >

<script type="text/javascript" charset="utf-8">
var countdown=60;
function settime(obj){
    if(countdown == 0){
        obj.removeAttribute("disabled");
        obj.value="获取校验码";
        countdown =60;
        return;
    }else{
        obj.setAttribute("disabled",true);
        obj.value="重新发送("+countdown+"s)";
        countdown--;
    }
    setTimeout(function(){settime(obj);},1000)
}
</script>

欢迎分享本文,转载请保留出处:前端ABC » 点击获取验证码倒计时

分享到:更多 ()

发表评论 0