美文网首页
js 验证码倒计时

js 验证码倒计时

作者: 怪我咯c | 来源:发表于2016-11-24 09:03 被阅读0次

1.js中使用倒计时用setTimeout()

<input type="button" id="sendCode" value="发送验证码" />

<script type="text/javaacript">

// 验证码 倒计时60秒

var wait=60;

function time(o) {

if (wait == 0) {

o.removeAttribute("disabled");

o.value="发送验证码";

wait = 60;

} else {

o.setAttribute("disabled", true);

o.value="重新发送(" + wait + ")";

wait--;

setTimeout(function() {

time(o)

},

1000)

}

}

document.getElementById("sendCode").onclick=function(){time(this);}

</script>

相关文章

网友评论

      本文标题:js 验证码倒计时

      本文链接:https://www.haomeiwen.com/subject/vflbpttx.html