MARK下,开发的时候用得到的。
原生的短信倒计时
<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>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);内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://sulao.cn/post/402
评论列表