JS 60秒倒计时

直接贴上代码:

<!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>

欢迎转载,原文地址:http://www.lrfun.com/html/technology/cssjs/2015/1126/93.html

上一篇:JS 获取当前时间戳,获取多少天后日期
下一篇:JS 正则表达式,验证表单