zoukankan      html  css  js  c++  java
  • Day3-----clock

    //------------------------通过获取系统时间,添加定时器和添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>

  • 相关阅读:
    SpringMVC框架搭建
    java事务的概念
    SpringMVC框架
    JAVA多线程面试题
    MD5加密
    java对象和xml的转换
    eclipse环境配置
    关于枚举类的使用
    定时器的使用
    关于AS-OS
  • 原文地址:https://www.cnblogs.com/fleshy/p/4114978.html
Copyright © 2011-2022 走看看