码迷,mamicode.com
首页 > Web开发 > 详细

js 发送短信验证码倒计时

时间:2018-10-18 21:57:12      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:NPU   count   set   pre   this   isa   value   btn   put   

 

html

<input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" />

 

 

js

 

// 短信验证码倒计时
var countdown=60;
function settime(obj) {
if (countdown == 0) {
obj.removeAttribute("disabled");
obj.value="免费获取验证码";
countdown = 60;
return;
} else {
obj.setAttribute("disabled", true);
obj.value="重新发送(" + countdown + ")";
countdown--;
}
setTimeout(function() {
settime(obj) }
,1000)
}



js 发送短信验证码倒计时

标签:NPU   count   set   pre   this   isa   value   btn   put   

原文地址:https://www.cnblogs.com/shuihanxiao/p/9813144.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!