亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - Verification code countdown
阿神
阿神 2017-05-19 10:33:06
0
1
676
<input type="button" id="btn" value="免費(fèi)獲取驗(yàn)證碼" onclick="settime(this)" /> 
<script type="text/javascript"> 
var countdown=60; 
function settime(val) { 
if (countdown == 0) { 
val.removeAttribute("disabled");  
val.value="免費(fèi)獲取驗(yàn)證碼"; 
countdown = 60; 
} else { 
val.setAttribute("disabled", true); 
val.value="重新發(fā)送(" + countdown + ")"; 
countdown--; 
} 
setTimeout(function() { 
settime(val) 
},1000) 
} 
</script> 

Could you please tell me that when the time times out after using this code, the method will automatically loop, but after deleting the setTimeout method, the code function cannot be realized. How to solve it?

阿神
阿神

閉關(guān)修行中......

reply all(1)
PHPzhong

Add a return ; and that’s it. I gave it a try.
<input type="button" id="btn" value="Get verification code for free" onclick="settime(this)" />
<script type="text/javascript">

var countdown=60; 
function settime(val) { 
if (countdown == 0) { 
    val.removeAttribute("disabled");  
    val.value="免費(fèi)獲取驗(yàn)證碼"; 
    countdown = 60; 
    return ; // 結(jié)束循環(huán)
} else { 
    val.setAttribute("disabled", true); 
    val.value="重新發(fā)送(" + countdown + ")"; 
    countdown--; 
} 
setTimeout(function() { 
    settime(val) 
    },1000) 
} 

</script>

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template