The implementation of the JavaScript pause and continue timer, javascript Timer
For the JavaScript timer, 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. Thank you very much for your support for the help House website!