获取验证码倒计时,js代码
2015-11-03 11:26
603 查看
<html><head>
<meta charset="utf-8">
</head>
<body>
<input type="button" id="btn" value="重新发送(26)" disabled="true">
<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>
wait为等待的时间,but为你获取验证码的按钮。
<meta charset="utf-8">
</head>
<body>
<input type="button" id="btn" value="重新发送(26)" disabled="true">
<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>
wait为等待的时间,but为你获取验证码的按钮。
相关文章推荐
- JS人民币数字转换成大写形式
- js 判断是否移动设备访问站点
- js冒泡、捕获事件及阻止冒泡方法详细总结
- JavaScript实现的Tween算法及缓冲特效实例代码
- JS 跨域问题
- js tap穿透问题
- JS 正则
- JS日期选择器
- PJSIP 添加视频的思路和想法
- Js文件中调用其它Js函数的方法
- 用js使得输入框input只能输入数字
- JS倒计时
- KindEditor 4.1.10 ,实用的一些要点,
- ngularJs项目实战05: 不同controller作用域之间通信的方式
- JavaScript
- js颜色选择器修改版(兼容firefox,chrome)
- js中的preventDefault与stopPropagation详解
- js复制到剪切板
- javascript 实现继承
- js正则表达式练习