Simple implementation JS countdown function

The example of this article shared the specific code of JS countdown, mainly using JS Date objects and timer setInterVal for your reference, the specific content is as follows

          VAR TIMSTR = '2020-09-03'; var_timer; // Execute Window.onLoad = function () {TimerFunc (); // call Timer Document.GtelementById ('TIMSPAN'). InnerHtml = TIMSTR; / / Timer FUNC = function () {_timer = setInterval ('tfunc ()', 1000); // generation timer} // Time processing method TFUNC = function () {var ntim = new date (); // Current timestamp Var_TM = TIMSTR.REPLACE (/ - / g, '\ /'); // Target time field skewers - replacement into /, formatted required VAR ftim = new Date (_TM); // Format Target Time VAR RS = TIMGAP (NTIM.GETTIME (), ftim.gettime ()); // Call Take time difference method var _STR = rs.d + '天 + rh +' hour '+ rs.m +' minute '+ rs.s +' Second '; // The data returned data spliced ​​string Document.GetElementByid (' GAP '). InnerHtml = _STR;// Output} // Take the time difference method TIMGAP = function (ntim, ftim) {var Date3 = ftim - ntim; // Time difference millisecond number var days = math.floor (DATE3 / (24 * 3600 * 1000)); // Take the number of days VAR Level1 = DATE3% (24 * 3600 * 1000); // The number of milliseconds left after the number of days, VAR Hours = Math.Floor (Level1 / (3600 * 1000)); // Take a few times VAR Level2 = Level1% (3600 * 1000); // Take the left number of milliseconds of milliseconds = Math.Floor (Level2 / (60 * 1000)); // Take the minute Var Level3 = Level2% (60 * 1000); // Take the remaining millix VAR seconds = math.floor (level3 / 1000); // 取 秒 = {}; // assignment TIM ['D'] = days; TIM [ 'h'] = Hours; TIM ['M'] = minutes; TIM ['S'] = Seconds; //Console.log (Tim); Return Tim; // Return Data}    Distance    
More about countdown, please view the topic: "Countdown Function"
More JavaScript clocks Specialties Click to view: JavaScript clock special effects
The above is all of this article, I hope to everyoneI have helpful, I hope everyone will support Tumi Clouds.
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment