js 代码中的 setTimeOut() 为什么时间不自动跟新???? 5
<html><head><scripttype="text/javascript">functiongetTime(){vartime=newDate();varhour...
<html>
<head>
<script type="text/javascript">
function getTime(){
var time=new Date();
var hour=time.getHours();
var minutes=time.getMinutes();
var seconds=time.getSeconds();
document.write("当前时间:"+hour+":"+minutes+":"+seconds);
setTimeOut("getTime()",1000);
}
</script>
</head>
<body onload="getTime()">
</body>
</html> 展开
<head>
<script type="text/javascript">
function getTime(){
var time=new Date();
var hour=time.getHours();
var minutes=time.getMinutes();
var seconds=time.getSeconds();
document.write("当前时间:"+hour+":"+minutes+":"+seconds);
setTimeOut("getTime()",1000);
}
</script>
</head>
<body onload="getTime()">
</body>
</html> 展开
3个回答
展开全部
<head>
<div id="dt_div"></div>
<script type="text/javascript">
function getTime() {
var time = new Date();
var hour = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
document.getElementById("dt_div").innerHTML = "当前时间:" + hour + ":" + minutes + ":" + seconds; //不能直接输出到页面
setTimeout(getTime, 1000);//o小写
}
</script>
</head>
<body onload="getTime()">
</body>
<div id="dt_div"></div>
<script type="text/javascript">
function getTime() {
var time = new Date();
var hour = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
document.getElementById("dt_div").innerHTML = "当前时间:" + hour + ":" + minutes + ":" + seconds; //不能直接输出到页面
setTimeout(getTime, 1000);//o小写
}
</script>
</head>
<body onload="getTime()">
</body>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
setTimeOut只执行一次你要执行多次的用setInterval
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询