動態獲取時間

<pre name="code" class="javascript"><!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div id="div11"></div>
		<script type="text/javascript">
			function getTimes(){
				//獲取時間
				var date = new Date();
				//格式化時間
				var d1 = date.toLocaleString();
				//獲取div
				var div11 = document.getElementById("div11");
				div11.innerHTML = d1;
			}
			//使用定時器實現每秒寫一次時間
			setInterval("getTimes()",1000);
		</script>
	</body>
</html>



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章