jQuery を利用するには、以下のように jQuery.ready() 内のコードを囲む
ことを忘れないでください:
jQuery(document).ready(function( $ ){
// あなたのコードをここに記述
});
--
別のサーバー上の JavaScript のファイルへリンクしたいなら
( と同じように)
これは、HTML コードなので「HTMLコードの追加」を使ってください。
コメント終わり */
document.addEventListener("DOMContentLoaded", function() {
function getDarkModeStatus(time) {
return time > 20 ? "dark" : "light";
}
const mode = getDarkModeStatus(new Date().getHours());
const darkmodeBox = document.querySelector(".darkmode-box");
if(darkmodeBox){
darkmodeBox.style.backgroundColor = mode === "dark" ? "#000" : "#fff";
darkmodeBox.style.color = mode === "dark" ? "#fff" : "#000";
}
function getSeason(month) {
if (month >= 3 && month <= 5) return "春";
if (month >= 6 && month <= 8) return "夏";
if (month >= 9 && month <= 11) return "秋";
return "冬";
}
const currentMonth = new Date().getMonth() + 1;
const season = getSeason(currentMonth);
const seasonDisplay = document.getElementById("season-display");
if(seasonDisplay){
seasonDisplay.textContent = `現在の月は ${currentMonth} 月なので、季節は ${season} です!`;
}
});