js,jq发送短信倒计时
2014-03-18 17:03
239 查看
js:
<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 { // www.jbxue.com
o.setAttribute("disabled", true);
o.value="重新发送(" + wait + ")";
wait--;
setTimeout(function() {
time(o)
},
1000)
}
}
document.getElementById("btn").onclick=function(){time(this);}
</script>
jq:(js的那个在我的项目上不是很好用自己写了一个jq的)
var step = 59;
$('#btn').val('重新发送60');
var _res = setInterval(function()
{
$("#btn").attr("disabled", true);//设置disabled属性
$('#btn').val('重新发送'+step);
step-=1;
if(step <= 0){
$("#btn").removeAttr("disabled"); //移除disabled属性
$('#btn').val('获取验证码');
clearInterval(_res);//清除setInterval
}
},1000);
<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 { // www.jbxue.com
o.setAttribute("disabled", true);
o.value="重新发送(" + wait + ")";
wait--;
setTimeout(function() {
time(o)
},
1000)
}
}
document.getElementById("btn").onclick=function(){time(this);}
</script>
jq:(js的那个在我的项目上不是很好用自己写了一个jq的)
var step = 59;
$('#btn').val('重新发送60');
var _res = setInterval(function()
{
$("#btn").attr("disabled", true);//设置disabled属性
$('#btn').val('重新发送'+step);
step-=1;
if(step <= 0){
$("#btn").removeAttr("disabled"); //移除disabled属性
$('#btn').val('获取验证码');
clearInterval(_res);//清除setInterval
}
},1000);
相关文章推荐
- js,jq发送短信倒计时
- js,jq发送短信倒计时
- js发送短信倒计时的简单实现方法
- 倒计时,短信发送后倒计时效果js
- jquery,js php 发送短信验证吗 前端 点击事件时间倒计时
- js实现发送短信验证码后的倒计时功能(无视页面刷新)
- 基于JS实现发送短信验证码后的倒计时功能(无视页面刷新,页面关闭不进行倒计时功能)
- js+servlet 实现发送短信验证码,并开始倒计时,进行验证
- js发送短信倒计时的简单实现
- JS实现发送短信验证后按钮倒计时功能(防止刷新倒计时失效)
- js实现5秒倒计时重新发送短信功能
- js实现发送短信验证码后的倒计时功能(无视页面刷新)
- js实现发送短信验证码后的倒计时功能(无视页面刷新)
- js实现短信发送倒计时功能(正则验证)
- js发送短信倒计时
- js实现发送短信验证码后的倒计时功能(无视页面刷新)
- VUE发送短信倒计时组件代码
- 发送短信验证后,按钮倒计时,防止刷新倒计时失效
- 短信发送倒计时(以及正则验证)
- 初探JS-html5移动端发送指定内容短信到指定号码