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
Recently, I have been working on a project and ne...
There are two ways: 1. Service method Check the f...
123WORDPRESS.COM--HTML超文本标记语言速查手册<!-- --> !D...
Why optimize: With the launch of the actual proje...
1. Modify the firewall configuration file # vi /e...
Table of contents From father to son: 1. In the s...
It is difficult to find good image material websi...
Table of contents 1. Get a random Boolean value (...
download: Step 1: Open the website (enter the off...
Table of contents one. environment two. Precautio...
How to uninstall Mysql perfectly? Follow the step...
See: https://www.jb51.net/article/112612.htm Chec...
1. Command method Run the nginx service in the cr...
W3C recently released two standards, namely "...
Nginx uses a fixed number of multi-process models...