<!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>
<head><title>简单的动态时钟</title><head>
<body onload="nowTime()">
<script type="text/javascript">
function nowTime(){var nowData = new Date();
var year = nowData.getYear();
var month = nowData.getMonth();
month += 1;
var day = nowData.getDate();
var hour = nowData.getHours();
var minute = nowData.getMinutes();
var second = nowData.getSeconds();document.getElementById("div1").innerText=year+"年"+month+"月"+day+"日"+hour+"点"+minute+"分"+second+"秒";
setTimeout("nowTime()",1000);
}</script>
<div id=div1>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<head><title>简单的动态时钟</title><head>
<body onload="nowTime()">
<script type="text/javascript">
function nowTime(){var nowData = new Date();
var year = nowData.getYear();
var month = nowData.getMonth();
month += 1;
var day = nowData.getDate();
var hour = nowData.getHours();
var minute = nowData.getMinutes();
var second = nowData.getSeconds();document.getElementById("div1").innerText=year+"年"+month+"月"+day+"日"+hour+"点"+minute+"分"+second+"秒";
setTimeout("nowTime()",1000);
}</script>
<div id=div1>
</div>
</body>
</html>
解决方案 »
- ExtJS4.1 非Iframe实现框架页问
- 【原创】JavaScript 图片预览效果
- firefox下disabled不能正常显示的问题
- javaScript做打印的时候怎么设置页面设置里面的参数
- 节点创建好了,事件也添加了,可是还要传当前节点对象参数不会
- 求javascript性能监视工具
- 请教一个简单问题
- 经过了一天的折磨之后,求救:把htmleditor包含在jsp里面的代码谁有啊?
- 急需javascript函数,输入参数为string,校验是否为YYYY.MM.DD日期格式?
- My97DatePicker IE9中,格式yyyy-MM和yyyy年MM月,显示不正常
- 急求,我想把一个字符串分割为45个字节为一个字符串,80个字节的字符串分为45字节和35字节的字符串
- 如何得到鼠标当前位置。在线等!
可以帮我解释一下document.getElementById("div1").innerText的作用吗,
一定要在body里onload,然后在层或其他地方使用吗?
古人说:授人以鱼不如授人以渔.呵呵,我贪心点了.........