倒计时60秒发送短信
作者:互联网
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>jQuery实现倒计时</title> 6 <body> 7 <input type="button" id="btn" value="免费获取验证码" onclick="sendemail()" /> 8 9 <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> 10 <script type="text/javascript"> 11 var countdown=60; 12 function sendemail(){ 13 var obj = $("#btn"); 14 settime(obj); 15 16 } 17 function settime(obj) { //发送验证码倒计时 18 if (countdown == 0) { 19 obj.attr('disabled',false); 20 obj.val("免费获取验证码"); 21 countdown = 60; 22 return; 23 } else { 24 obj.attr('disabled',true); 25 obj.val("重新发送(" + countdown + ")"); 26 countdown--; 27 } 28 setTimeout(function() { 29 settime(obj) } 30 ,1000) 31 } 32 </script> 33 </body> 34 </html>
标签:function,倒计时,短信,countdown,60,settime,obj 来源: https://www.cnblogs.com/sunho/p/16519305.html