当前位置: 移动技术网 > IT编程>网页制作>Html5 > 验证码倒计时

验证码倒计时

2019年11月20日  | 移动技术网IT编程  | 我要评论

验证码倒计时

 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.aspx

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网