script.js

来自「lynda.com 2007年出品的javascript essential t」· JavaScript 代码 · 共 34 行

JS
34
字号
window.onload = showTheTime;function showTheTime() {	var now = new Date();	var theTime = showTheHours(now.getHours()) + showZeroFilled(now.getMinutes()) + showZeroFilled(now.getSeconds()) + showAmPm();	document.getElementById("showTime").innerHTML = theTime;	setTimeout("showTheTime()",1000);		function showTheHours(theHour) {		if (theHour == 0) {			return 12;		}		if (theHour < 13) {			return theHour;		}		return theHour-12;	}		function showZeroFilled(inValue) {		if (inValue > 9) {			return ":" + inValue;		}		return ":0" + inValue;	}		function showAmPm() {		if (now.getHours() < 12) {			return " am";		}		return " pm";	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?