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
Introduction to Vue The current era of big front-...
There are many tags in XHTML, but only a few are ...
Here are 10 tips on how to design better-usable w...
Table of contents 1. The principle of index push-...
HTML code: <a onclick="goMessage();"...
In HTML, the Chinese phrase “學好好學” can be express...
First, the server environment information: Reason...
Concept introduction : 1. px (pixel): It is a vir...
1. Modify my.cnf #The overall effect is that both...
After I finished reading JavaScript DOM, I had a ...
background Before starting the article, let’s bri...
My machine environment: Windows 2008 R2 MySQL 5.6...
Solve the problem that the responseText returned ...
Table of contents 1. Effect diagram (multiple col...
<br />In general guestbooks, forums and othe...