日期:2014-05-16 浏览次数:20658 次
初探js特效魅力之简易时钟的使用one
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js特效</title>
<!-- <link id="link1" rel="stylesheet" type="text/css" href="css1.css" />-->
<script>
window.onload=function(){
function toD(n){
if(n<10){
return '0'+n;
}
else{
return ''+n;
}
}
var oImg=document.getElementsByTagName("img");
function tick(){
var oDate=new Date();
var str=toD(oDate.getHours())+toD(oDate.getMinutes())+toD(oDate.getSeconds());
for(var i=0;i<str.length;i++){
oImg[i].src=str.charAt(i)+".jpg";
}
}
setInterval(tick,1000);
tick();
}
</script>
<style>
img{
width:50px;
height:70px;
}
label{
font-size:70px;
}
</style>
</head>
<body>
<img src="0.jpg" />
<img src="0.jpg" />
<label>:</label>
<img src="0.jpg" />
<img src="0.jpg" />
<label>:</label>
<img src="0.jpg" />
<img src="0.jpg" />
</body>
</html>