This article mainly introduces the related information about the methods for pausing and resuming the timer in JavaScript, which is very good. If you need it, you can refer to it. For JavaScript timers, there is no strict pause or restart, only the stop is cleared, but it can be implemented through some 'blind-eye method '.
AllChild [index]. onclick = function () {// when the target is clicked and the following conditions are met, set the timer time to suspend if (gamInt = true) {$ ("# tu" ).css ("display", "block"); // timer pause (clear timer) clearInterval (countdownTimer ); // after a latency of 2 seconds, the game continues to pause the timer and ends. setTimeout (function () {// remove all images removeImgFun (); $ ("# tu" ).css ("display ", "none"); imgNum ++; if (imgNum> = 10) {imgNum = 10;} createImgFun (); // The timer is added before it is connected (the previous timer is re-referenced to include the name of the timer once (it must be available or it is easy to cause computer crashes) countdownTimer = setInterval (Function () {countdownNum-= 0.01; // retain two decimal places countdownNum = countdownNum. toFixed (2); if (countdownNum <= 0) {clearInterval (countdownTimer); // the game ends alert ("the game ends! "); // The ancestral home name cannot be clicked (score no longer counted) gamInt = false;} time. innerHTML = "Countdown:" + countdownNum + "seconds" ;}, 10) ;}, 2000) // score scores + = 1; score. innerHTML = "" + scores + ""; if (scores> 8) {$ ("# wc" ).css ("display", "block "); $ ("# haha" ).css ("display", "none"); $ ("# cj "). on ("click", award (); $ ("# sm "). on ("click", explain ());}}}
The above is a small Editor to introduce you to the JavaScript pause and continue timer method, I hope to help you, if you have any questions, please leave a message, the small editor will reply to you in a timely manner. I would like to thank you for your support for PHP chinnet!
For more articles about how to implement JavaScript pause and continue timer, please follow the PHP Chinese network!