我試圖改變基於時間這個元素:文本變化元件基於時間
我發現這個片段,但我該怎麼改變/添加,這樣它會影響H1?
var myDate = new Date();
/* hour is before noon */
if (myDate.getHours() < 12) {
document.write("Good Morning!");
}
/* Hour is from noon to 5pm (actually to 5:59 pm) */
else if (myDate.getHours() >= 12 && myDate.getHours() <= 17) {
document.write("Good Afternoon!");
}
/* the hour is after 5pm, so it is between 6pm and midnight */
else if (myDate.getHours() > 17 && myDate.getHours() <= 24) {
document.write("Good Evening!");
}
/* the hour is not between 0 and 24, so something is wrong */
else {
document.write("I'm not sure what time it is!");
}
在此先感謝!
我沒有找到任何元素.... – Rayon