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