如何在表格中套入时间
答案:3 悬赏:10 手机版
解决时间 2021-05-11 21:28
- 提问者网友:寂寞梧桐
- 2021-05-11 14:23
我想在表格里面套入一个可以活动的时间,就感觉象在表格里面加了一个时钟一样,可以走的那种比如现在是13:36下一秒是13:37,反正它要和真正的时间一样走动就对了,请问谁可以帮助我?
最佳答案
- 五星知识达人网友:十鸦
- 2021-05-11 15:39
你好:
将下列代码保存为time.htm预览即可
<script >
setInterval(time, 1000);
function time()
{
var now=new Date();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
var out = "";
out = hour + "时" + minute + "分" + second + "秒" ;
document.getElementById("show").innerHTML = out;
}
</script>
<body>
<table border="1" cellpadding="1" cellspacing="1">
<tr>
<td >
时间</td>
<td id = "show" >
</td>
</tr>
</table>
</body>
全部回答
- 1楼网友:平生事
- 2021-05-11 16:49
二姐,可以给我讲我教你
- 2楼网友:刀戟声无边
- 2021-05-11 15:54
<html>
<head>
<title>倒计时</title>
<body>
<script language=JavaScript>
var now = new Date("11/26/2006 " + 10 + ":" + 30 + ":" + 30);
function GetServerTime()
{
var urodz = new Date("11/30/2006 11:38:33");
now.setTime(now.getTime()+250);
days = (urodz - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (urodz - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (urodz - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (urodz - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);
document.getElementById("date").innerHTML = daysRound;
document.getElementById("time").innerHTML = hoursRound + ":" + minutesRound + ":" + secondsRound;
}
setInterval("GetServerTime()",250);
</script>
<table><tr>
<td>
距离********还有<span id="date"></span> <span class="white14b">天</span> <span id="time"></span></td>
</tr>
</table>
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯