驗證碼倒計時

驗證碼倒計時html

 1 <style>
 2     .btn{
 3         color:red;
 4     }
 5     .dian{
 6         color:green;
 7     }
 8 </style>
 9 <body>
10     <input type="button" class="btn" value="獲取驗證碼" onclick="dao(15,this)">
11 </body>
12 </html>
13 <script src="jquery-1.8.1.min.js"></script>
14 <script>
15     var shi 
16     function dao(miao,obj){
17         if(miao > 1){
18             miao --;
19             miao > 9 ? shi = miao :shi = "0" + miao; 
20             $(obj).val(shi + '' + "s後重試").attr("disabled",true);  //按鈕禁用
21             $(obj).addClass("dian");
22             setTimeout(function(){
23                 dao(miao,obj)
24             },1000);
25         }else{
26             $(obj).val("獲取驗證碼").attr("disabled",false)  //按鈕可用
27             $(obj).removeClass("dian");
28         }
29     }
30 </script>

 博客園模板  http://www.cnblogs.com/Skins.aspxjquery

相關文章
相關標籤/搜索