多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
~~~ <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> span{ font-size: 30px; } body{ background-color: black;color: #fff; } </style> </head> <body> <div> <img src="images/0.png" alt=""/> <img src="images/0.png" alt=""/> <span>:</span> <img src="images/0.png" alt=""/> <img src="images/0.png" alt=""/> <span>:</span> <img src="images/0.png" alt=""/> <img src="images/0.png" alt=""/> </div> <script> function getDouble(n){ if(n<10){ return "0"+n; }else{ return ""+n; } } showTime(); function showTime(){ /*1.获取系统时间*/ var oDate = new Date(); var hour = oDate.getHours(); var minute = oDate.getMinutes(); var second = oDate.getSeconds(); /*2.显示系统时间 *a字符串连接 定义方法实现 *b空零补位 * */ var imgs = document.getElementsByTagName("img"); var str = getDouble(hour)+getDouble(minute)+getDouble(second); console.log(str) for(var i=0;i<imgs.length;i++){ imgs[i].src="images/"+str[i]+".png" } } setInterval(showTime,1000) </script> </body> </html> ~~~