如何确保每天将计时器设置为半 4,这样我就不必在 Javascript 中提及某个日期?此外,如何以 div 或 p 而不是表单显示输出。
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>jQuery Countdown</title>
</head>
<body>
<script language="javascript" type="text/javascript">
function getTime() {
now = new Date();
orderBy = new Date("May 17 2016 16:30:00");
//days = (orderBy - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (orderBy - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (orderBy - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (orderBy - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);
sec = (secondsRound == 1) ? "" : "";
min = (minutesRound == 1) ? " : " : " : ";
hr = (hoursRound == 1) ? " : " : " : ";
//dy = (daysRound == 1) ? " day" : " days, ";
document.timeForm.input1.value = "Check again before " + hoursRound + hr + minutesRound + min + secondsRound + sec;
newtime = window.setTimeout("getTime();", 1000);
}
window.onload=getTime;
if (days = 0){
days.style.display = "none";
}
</script>
<form name=timeForm>
<input type=text name=input1 size=50 border-style="none" style="display: block; border: none; font-size: 14px; font-family: sans-serif">
</form>
</body>
</html>