码迷,mamicode.com
首页 > Web开发 > 详细

jQuery获取验证码简单demo

时间:2015-07-14 19:48:34      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:

[转自]  http://q.cnblogs.com/q/45695/

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4 <meta charset="utf-8">
 5 <title>获取验证码</title>
 6 <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js" ></script>
 7 <script type="text/javascript">
 8     $(function () {
 9         $("#btnCode").click(function () {
10             // alert(‘message‘);
11             //执行获取验证码的操作
12             GetNumber();
13         });
14     });
15     var count = 3;
16     function GetNumber() {
17         $("#btnCode").attr("disabled", "disabled");
18         $("#btnCode").val(count + "秒之后点击获取")
19         count--;
20         console.log(count);
21         if (count > 0) {
22             setTimeout(GetNumber, 1000);
23         }
24         else {
25             $("#btnCode").val("点击获取验证码");
26             $("#btnCode").removeAttr("disabled");
27             count = 3;//注意此处需添加count = 3
28         }
29     }
30 </script>
31 </head>
32 <body>
33     <form>
34         <input id="btnCode" type="button" value="点击获取验证码"/>
35     </form>
36 </body>
37 </html>

 

jQuery获取验证码简单demo

标签:

原文地址:http://www.cnblogs.com/k11590823/p/4646342.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!