Some scenarios for register-based, click Send code, xx seconds after the re-transmission.
SetTimeout method using, xx seconds after performing the specified method, modify an attribute value of button, Disabled is true gray, not click.
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!--<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>--> <script type="text/javascript"> var countdown=60; function settime(obj) { if (countdown == 0) { obj.removeAttribute("Disabled " ); obj.value = " Get codes " ; COUNTDOWN = 60 ; return ; } the else { obj.setAttribute ( " Disabled " , to true ); obj.value = " Resend ( " + COUNTDOWN + " ) " ; COUNTDOWN - ; } the setTimeout ( function () { setTime (obj); } ,1000); } </script> <body> <label> <input type="text" name="textfield"> </label> <input type="button" id="btn" value="获取验证码" onclick="settime(this)" /> </body> </html>