好好爱自己!

简单的js实现网页时钟

js实现时钟。

<div id="clock"></div>

<script type="text/javascript">

  function ChangeClock()

    {

      var time=new Date();

      document.getElementById("clock").innerHTML="当前时间:"+time.getFullYear()+"年"+(time.getMonth()+1)+"月"+time.getDate()+"日 "+time.getHours()+":"+time.getMinutes()+":"+time.getSeconds();

    }

      window.setInterval(ChangeClock,1000);

</script>

posted @ 2015-07-22 17:03  立志做一个好的程序员  阅读(1259)  评论(0编辑  收藏  举报

不断学习创作,与自己快乐相处