<!DOCTYPE html>
<html>
<head>
	<title>实时动态时间显示</title>
	<script>
		function updateTime() {
			var now = new Date();
			var hours = now.getHours();
			var minutes = now.getMinutes();
			var seconds = now.getSeconds();
			var timeString = hours + ":" + minutes + ":" + seconds;
			document.getElementById('time').innerHTML = timeString;
		}
<pre><code>	window.onload = function() {
		updateTime();
		setInterval(updateTime, 1000);
	};
&lt;/script&gt;
</code></pre>
</head>
<body>
	<div id='time'></div>
</body>
</html>

原文地址: https://www.cveoy.top/t/topic/nVof 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录