标签:time() 标题 date() add 文档 e30 art span file
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<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" />
<script src="js/myJs_file.js"></script>
<script>
var aImg = document.getElementsByTagName("img");
function showTime(){
var myTime = new Date();
var iHours = myTime.getHours();
var iMinutes = myTime.getMinutes();
var iSeconds = myTime.getSeconds();
var str = addZero(iHours)+addZero(iMinutes)+addZero(iSeconds);
for(var i=0;i<str.length;i++){
aImg[i].src = "img/" + str.charAt(i) + ".JPG";
}
}
setInterval(showTime, 1000);
showTime();
</script>
</body>
</html>
ps: myJs_file.js里面其实就是一个利用三目运算符判断数字是否大于10,当大于10时,输出;小于10,则给该数字前面加0;
标签:time() 标题 date() add 文档 e30 art span file
原文地址:http://www.cnblogs.com/y5w2z1/p/7563528.html