This article mainly introduces the countdown button for js implementation. The example analyzes the implementation skills related to the countdown effect for javascript. if you need it, refer to the example in this article to describe the countdown button for js implementation. Share it with you for your reference. The specific analysis is as follows:
As follows:
The code is as follows:
Var secs = 3; var wait = secs * 1000; var update = function (num, value) {if (num = (wait/1000 )) {$ ("# rulesubmit "). val ("Get Free");} else {printnr = (wait/1000)-num; $ ("# rulesubmit "). val ("Get Free (" + printnr + ")") ;}}; var timer = function () {$ ("# rulesubmit "). attr ("disabled", false); $ ("# rulesubmit "). val ("Get Free") ;};$ (function () {function getValidateCode () {$ ("# rulesubmit "). val ("get for free (" + secs + ")"); $ ("# rulesubmit "). attr ("disabled", true); for (I = 1; I <= secs; I ++) {window. setTimeout ("update (" + I + ")", I * 1000);} window. setTimeout ("timer ()", wait) ;}$ ("# rulesubmit "). click (function () {getValidateCode () ;}) ;}(); // Note: I changed it to an anonymous function during the test, in fact, you can implement // getValidateCode () as a separate function without doing so, and execute the function at $ (function () {// Click the button, that is, the above blue code;}); script
Here is just a small example. In practice, you may need to record various times. Considering the changes in page refresh, you need to use cookies to store data!
I hope this article will help you design javascript programs.