Js: Click to get the verification code countdown effect, js get the verification code countdown Effect
In order to prevent malicious access to verification text messages and email addresses, the website performs a countdown by clicking the get verification code button. To implement this function, one setInterval and one clearInterval can be done without too much code. The instance effect and Code are as follows:
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> <input type = "button" style = "height: 32px; width: 120px; "value =" click to send the verification code "onclick =" sendCode (this) "/> <script type =" text/javascript "> var clock = ''; var nums = 10; var btn; function sendCode (thisBtn) {btn = thisBtn; btn. disabled = true; // do not click btn. value = nums + 'can be retrieved again in seconds'; clock = setInterval (doLoop, 1000); // one-second execution} function doLoop () {nums --; if (nums> 0) {btn. value = nums + 'can be retrieved again in seconds';} else {clearInterval (clock); // clear js timer btn. disabled = false; btn. value = 'send Verification Code click'; nums = 10; // reset time }}</script>
Using setInterval and clearIntervaljs, you can click js to obtain the verification code countdown effect. I hope this will be helpful for your learning.