jQuery实现发送短信验证码后60秒倒计时

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <script src="js/jquery-1.9.1.min.js"></script>
 5 <script type="text/javascript"> 
 6 var countdown=60; 
 7 function settime(obj) { 
 8     if (countdown == 0) { 
 9         obj.removeAttribute("disabled");    
10         obj.value="获取验证码"; 
11         countdown = 60; 
12         return;
13     } else { 
14         obj.setAttribute("disabled", true); 
15         obj.value="重新发送(" + countdown + ")"; 
16         countdown--; 
17     } 
18 setTimeout(function() { 
19     settime(obj) }
20     ,1000) 
21 }
22   
23 </script>
24 <body> 
25 <input type="button" id="button1" value="获取验证码" onclick="settime(this)" /> 
26   
27 </body>
28 </html>
原文地址:https://www.cnblogs.com/lilyshy/p/6382322.html