1
我想通過獲取用戶時間更改css。如果現在的時間是06:00-12:00,請使用Morning風格。時間12:00-18:00獲得下午風格。時間18:00-06:00獲得夜晚風格。否則得到正常風格...如何做到這一點。使用獲取時間更改樣式CSS Javascript
function morning() {
document.getElementsByTagName('BODY')[0].style.backgroundColor = "#fcfcfc";
document.getElementsByTagName('BODY')[0].style.color = "#505050";
}
function afternoon() {
document.getElementsByTagName('BODY')[0].style.backgroundColor = "gainsboro";
document.getElementsByTagName('BODY')[0].style.color = "black";
}
function night() {
document.getElementsByTagName('BODY')[0].style.backgroundColor = "#1b1b1b";
document.getElementsByTagName('BODY')[0].style.color = "#fff";
}
function normal() {
document.getElementsByTagName('BODY')[0].style.backgroundColor = "#fff";
document.getElementsByTagName('BODY')[0].style.color = "#1b1b1b";
}
可能的重複[在JavaScript中獲取當前日期和時間](http://stackoverflow.com/questions/10211145/getting-current-date-and-time-in-javascript) –