<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>验证码倒计时</title>
<style type="text/css">
input{ outline: none; border: none;}
.com{width: 120px; height: 35px; line-height: 35px; color: #fff; border-radius: 5px; }
.send{ background-color: #F08326; cursor: pointer;}
.send-d{ background-color: #CFCFCF; cursor:default;}
</style>
</head>
<body>
<input type="button" value="获取验证码" class="com send" id="btn">
<script type="text/javascript" src="jquery-1.11.3.min.js"></script>
<script type="text/javascript">
var wait = 60;
var btn=$("#btn");
//var btn=document.getElementById("btn");
btn.disabled=false;
function time(t) {
if (wait == 0) {
t.removeAttribute("disabled");
t.value="获取验证码";
btn.removeClass("send-d");
btn.addClass("send");
wait = 60;
} else {
t.setAttribute("disabled", true);
t.value = "重新发送(" + wait + ")";
btn.removeClass("send");
btn.addClass("send-d");
wait--;
setTimeout(function() {time(t)},1000);
}
}
btn.bind("click",function(){
time(this);
})
// btn.onclick = function() {
// time(this);
// }
</script>
</body>
</html>
验证码倒计时
最新推荐文章于 2023-11-29 15:30:15 发布