jquery获取验证码按钮倒计时

富辰阳
2023-12-01

<input type="button" id="btn" value="免费获取验证码" οnclick="settime(this)" />
    <script type="text/javascript">
        var countdown = 10;
        function settime(val) {
            if (countdown == 0) {
                val.removeAttribute("disabled");
                val.value = "免费获取验证码";
                countdown = 60;
            } else {
                val.setAttribute("disabled", true);
                val.value = "重新发送(" + countdown + ")";
                countdown--;
                setTimeout(function () {
                    settime(val)
                }, 1000)
            }

        } 
    </script>
 类似资料: