This article example shares the specific code of JS to realize the picture digital clock for your reference. The specific content is as follows First, this is the picture we prepared <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> </style> </head> <body> <div> <img src="img/0.png" alt=""> <img src="img/0.png" alt=""> <img src="img/10.png" alt=""> <img src="img/0.png" alt=""> <img src="img/0.png" alt=""> <img src="img/10.png" alt=""> <img src="img/0.png" alt=""> <img src="img/0.png" alt=""> </div> <script type="text/javascript"> //Function function get(){ //Get the page img var img = document.getElementsByTagName('img'); //Get time var date=new Date(); var hour=date.getHours(); var minute=date.getMinutes(); var secind=date.getSeconds(); //Fill in 0 if(hour<10){ hour='0'+hour; }else if(minute<0){ minute='0'+minute; }else if (secind) { secind='0'+secind; } // string concatenation img[0].src='img/'+parseInt(hour/10)+'.png'; img[1].src='img/'+hour%10+'.png'; img[3].src='img/'+parseInt(minute/10)+'.png'; img[4].src='img/'+minute%10+'.png'; img[6].src='img/'+parseInt(secind/10)+'.png'; img[7].src='img/'+secind%10+'.png'; } get(); setInterval(get,1000); //Call to refresh every second</script> </body> </html> Final implementation 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:
|
<<: Detailed explanation of the murder caused by a / slash in Nginx proxy_pass
>>: Solution to the problem of mysql master-slave switch canal
1. mpstat command 1.1 Command Format mpstat [ -A ...
Automated project deployment is more commonly use...
Introduction to MQTT MQTT (Message Queuing Teleme...
1. Four startup methods: 1.mysqld Start mysql ser...
Why do you need to learn CSS overflow mechanism i...
Arrow function is a new feature in ES6. It does n...
Table of contents 1 A brief introduction to syste...
In daily website maintenance and management, a lo...
It is almost a standard feature for websites nowa...
Description: Limit the number of lines of text di...
Preface This article will share some docker-compo...
Page directory structure Note that you need to mo...
The login interface of WeChat applet is implement...
Overview In the previous chapter, we learned abou...
When using Maven to manage projects, how to uploa...