A simple js timing function (multiple timing)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> h1{text-align:center;font-size:40px;} </style> </head> <body> <h1 > <!-- Countdown and 01hour01point01Second --> </h1> <script> //Set the countdown time range var seconds = 1000; //Manually call the timing function timeRun(); //Timed function call var timer = setInterval(timeRun, 1000); //Countdown function function timeRun(){ //Get h1 var h1 = ('number'); //judge if (seconds <= 0) { = "Game Over"; = "120px"; clearInterval(timer); return; } //Calculate the number of hours contained in seconds var h = (seconds / 3600); //Calculate the remaining seconds var s = seconds - h * 3600; //Removing from the remaining seconds var m = (s / 60); //Calculate the remaining seconds s -= m * 60; // Process the number <10 before adding 0 h = (h<10)?'0'+h:h; m = (m<10)?'0'+m:m; s = (s<10)?'0'+s:s; //Split string var message = "The countdown is still there"+h+'hour'+m+'point'+s+'Second'; //Output string to h1 = message; //The number of seconds is reduced seconds --; } </script> </body> </html>
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.