html代码:
<input type="button" value="获取验证码" id="getCode" style="color:#4664E6;background:white;" />
Jquery代码:别忘了引用jquery库
<script type="text/javascript"> var countdown = 60; $(function () { $("#getCode").bind("click", function () { settime(); }); }) function settime(e) { if (countdown == 0) { countdown = 60; $("#getCode").val("获取验证码"); $("#getCode").removeAttr("disabled"); return false; } else { countdown--; $("#getCode").val(countdown + "秒后重新获取"); $("#getCode").attr("disabled", "disabled"); } setTimeout(function () { settime(); }, 1000); } </script>