Js resend the second click Send code xx

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>

 

Guess you like

Origin www.cnblogs.com/ymmt/p/11268307.html