标签:
[转自] 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>
标签:
原文地址:http://www.cnblogs.com/k11590823/p/4646342.html