代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数码时钟</title>
<style>
img {
width:50px;
height:50px;
}
</style>
<script>
function toDou(n){
if(n<10){
return '0'+n;
}
else{
return ''+n;
}
}
window.onload=function(){
var aImg=document.getElementsByTagName('img');
function tick(){
var oDate=new Date();
var str=toDou(oDate.getHours())+toDou(oDate.getMinutes())+toDou(oDate.getSeconds());
for(var i=0;i<aImg.length;i++)
{
aImg[i].src='img/'+str[i]+'.jpg';
}
}
setInterval(tick,1000);
tick();
};
</script>
</head>
<body style="background:black; color:while; font-size:50px;">
<img src="img/0.jpg" />
<img src="img/0.jpg" />
:
<img src="img/0.jpg" />
<img src="img/0.jpg" />
:
<img src="img/0.jpg" />
<img src="img/0.jpg" />
</body>
</html>
图片资源