今天向大家分享一下网页上动态时间效果的实现,代码很简单:
\n<html>
\n<body onload=”setInterval(timerun,1000);timerun();”>
\n<span id=”mytime”></span>
\n<script type=”text/javascript”>
\nfunction timerun()
\n{
\nvar d=new Date();
\nvar s=d.getFullYear()+”年”+(d.getMonth()+1)+”月”+d.getDate()+”日 “+d.getHours()+”时”+d.getMinutes()+”分”+d.getSeconds()+”秒”;
\ndocument.getElementById(“mytime”).innerHTML=s;
\n}
\n</script>
</body>
\n</html>
\n