37 lines
843 B
HTML
37 lines
843 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Dark Mode Test</title>
|
|
<link rel="stylesheet" href="style.css" />
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Dark Mode Test</h1>
|
|
<p>This is a simple dual-file dark mode website.</p>
|
|
|
|
<button id="toggle">Toggle Dark Mode</button>
|
|
</div>
|
|
|
|
<script>
|
|
const toggle = document.getElementById("toggle");
|
|
|
|
// Load saved theme
|
|
if (localStorage.getItem("theme") === "dark") {
|
|
document.body.classList.add("dark");
|
|
}
|
|
|
|
toggle.addEventListener("click", () => {
|
|
document.body.classList.toggle("dark");
|
|
|
|
// Save theme
|
|
if (document.body.classList.contains("dark")) {
|
|
localStorage.setItem("theme", "dark");
|
|
} else {
|
|
localStorage.setItem("theme", "light");
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|