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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM