代码语言:javascript复制
<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>