JS 60秒倒计时
发表时间: 2015-11-26 16:31:21 | 浏览次数:
直接贴上代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>60秒倒计时</title>
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<input type="button" id="btn" value="免费获取验证码" onclick="settime($(this), 60)" />
<script type="text/javascript">
settime($("#btn"), 0);
function settime(val, countdown) {
if (countdown == 0) {
val.removeAttr("disabled");
val.val("免费获取验证码");
} else {
val.attr("disabled", true);
val.val("重新发送(" + countdown + ")");
countdown--;
setTimeout(function() { settime(val, countdown) },1000);
}
}
</script>
</body>
</html>
上一篇:JS 获取当前时间戳,获取多少天后日期
下一篇:JS 正则表达式,验证表单