javascript实现验证码60s倒计时源码下载

复制下面代码运行即可,自己可在添加样式美化一下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>验证码60s代码实现_淘拜网</title>
</head>
<script src="http://apps.bdimg.com/libs/jquery/1.4.2/jquery.min.js"></script>
<body>
<input type="button" id="btn" value="免费获取验证码" />
<script type="text/javascript">
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("btn").onclick=function(){time(this);}
</script>
</body>
</html>
正在加载评论...