This article example shares the specific code of js to implement a simple countdown for your reference. The specific content is as follows Code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="./3. Fill zero when less than 10.js"></script> <style> div { float: left; width: 100px; height: 100px; background-color: #000; text-align: center; line-height: 100px; color: #fff; font-size: 30px; margin-right: 10px; } </style> </head> <body> <div></div> <div></div> <div></div> <div></div> <script> var div = document.getElementsByTagName('div'); var inputTime = +new Date('2021-02-05 00:00:00'); //The total number of milliseconds from the user input time to January 1, 1970 setInterval(countTime, 1000); countTime(); function countTime() { var nowTime = +new Date(); //Total number of milliseconds from the current time to January 1, 1970 // console.log(timer); var times = (inputTime - nowTime) / 1000; // seconds var d = parseInt(times / 60 / 60 / 24); // days div[0].innerHTML = addZero(d) + 'days'; var h = parseInt(times / 60 / 60 % 24) //div[1].innerHTML = addZero(h) + 'time'; var m = parseInt(times / 60 % 60); //div[2].innerHTML = addZero(m) + '分'; var s = parseInt(times % 60); //seconds div[3].innerHTML = addZero(s) + 'seconds'; } </script> </body> </html> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: mysql 5.7.11 winx64.zip installation and configuration method graphic tutorial
>>: Detailed explanation of Linux server status and performance related commands
Menu bar example 1: Copy code The code is as foll...
1. IT Mill Toolkit IT Mill Toolkit is an open sou...
This article introduces some issues about HTML ta...
In more and more websites, the use of XHTML is rep...
This article example shares the specific code of ...
Utilize the browser's non- overflow:auto elem...
Regarding the nginx panic problem, we first need ...
1. Setting up nginx virtual host With virtual hos...
Table of contents Array deduplication 1. from() s...
illustrate This article was written on 2017-05-20...
In some scenarios, we need to modify our varchar ...
Introduction The mysql-utilities toolset is a col...
The :not pseudo-class selector can filter element...
1. Delete file command: find the corresponding di...
According to null-values, the value of null in My...