首页 > 其他 > 详细

Day3-----clock

时间:2014-11-22 13:16:29      阅读:207      评论:0      收藏:0      [点我收藏+]

//------------------------通过获取系统时间,添加定时器和添0操作完成日期和时间的显示

<html>
<head><title>clock</title></head>
<style type="text/css">
body{font-size: 25px;vertical-align: top;}
</style>
<script type="text/javascript">
function addZero(str){
if(str<10) return ‘0‘+str;
else return str;
}
function updateTime(){
var date=new Date();
oImg=document.getElementsByTagName(‘img‘);
var str=‘‘+date.getFullYear()+addZero((date.getMonth()+1))+addZero(date.getDate())+date.getDay()+addZero(date.getHours())+addZero(date.getMinutes())+addZero(date.getSeconds());
for(i=0;i<oImg.length;i++){
oImg[i].src="pic/"+str[i]+".png";
}
}
window.onload=function(){
updateTime();
setInterval(updateTime,1000);
}
</script>
<body>
<img><img><img><img>/
<img><img>/
<img><img>
The <img>th
<br/>
<img><img>:
<img><img>:
<img><img>
</body>
</html>

Day3-----clock

原文:http://www.cnblogs.com/fleshy/p/4114978.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!