復制代碼 代碼如下:
<html>
<head>
<script language = "javascript" type = "text/javascript">
function showTime(){
//在元素間的文本就是通過 對象 .innerText
document.getElementById("mytime").innerText = new Date().toLocaleString();
}
setInterval("showTime()",1000);
</script>
</head>
<body>
<span id = "mytime"></span>
</body>
</html>