js 簡單的網頁時鐘 – Javascript教程_JS教程_技術文章 – 程式設計聯盟

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔www.aiwalls.com</title>
<script language="javascript" type="text/javascript">
function shizhong(){
 var date = new Date();
 document.getElementById("timep").innerHTML=date.toLocaleString();
 }
 setTimeout("shizhong()",1000);
</script>
</head>
<body onload="shizhong()">
<p id="timep" style="background-color:#FF0000"></p>
</body>
</html>

摘自 youngerhao的專欄

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *