How to write the code for JavaScript to realize the CAPTCHA countdown?
This article mainly explains "how to write the code for JavaScript implementation of Captcha countdown". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian slowly and deeply to study and learn "how to write the code for JavaScript implementation of Captcha countdown" together!
JavaScript implementation Captcha countdown method: first create an HTML sample file; then create a button; finally by "$('. hmac').on ('click',function(){...} "Method Get the Captcha and count down for 60 seconds.
Operating environment of this article: Windows 7 system, Javascript version 1.8.5, Dell G3 computer.
How does JavaScript implement Captcha countdown?
js Get Captcha Countdown 60s(Super Simple)
Testing jquey's ajax methods *{ padding:0; margin:0; } button{width: 20%;line-height: 50px;font-size: 30px;margin-left: 40%;margin-top: 20%; } Get Captcha $('. hmac').on ('click ',function(){ var that = $(this) var timeo = 60; var timeStop = setInterval(function(){ timeo--; if (timeo>0) { that.text ('resend ' + timeo +' s'); that.attr ('disabled ',' disabled');//disable clicking }else{ timeo = 60;//assigned 60 when decremented to 0 that.text ('Get Captcha '); clearInterval(timeStop);//clear timer that.removeAttr ('disabled ');//Remove attributes, clickable } },1000)}) Thank you for reading, the above is "JavaScript implementation Captcha countdown code how to write" content, after the study of this article, I believe that we have a deeper understanding of JavaScript implementation Captcha countdown code how to write this problem, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!