点击倒数计时重新发送

 1 <!doctype html>
 2 <html lang="en">
 3 
 4     <head>
 5         <meta charset="UTF-8">
 6         <title>Document</title>
 7         <script type="text/javascript">
 8             window.onload = function(){
 9                 var send = document.getElementById('send');
10                 var time = 30;
11                 var timer = null;
12                 
13                 send.onclick = function(){
14                     timer = setInterval(changeInner, 1000);
15                 }
16                 
17                 function changeInner(){
18                     time--;
19                     send.value = time + '秒后重新发送';
20                     send.disabled = 'disabled';
21                     if(time === 0) {
22                         time = 30;
23                         send.disabled = '';
24                         send.value = '重新发送';
25                         clearInterval(timer);
26                     }
27                 }
28             }
29         </script>
30     </head>
31 
32     <body>
33         <input type="button" id="send" value="发送验证码">
34     </body>
35 
36 </html>

 

posted @ 2016-02-02 15:57  duchushouxin  阅读(102)  评论(0)    收藏  举报