-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (28 loc) · 1.15 KB
/
script.js
File metadata and controls
38 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
document.addEventListener("DOMContentLoaded", () => {
const themeSwitch = document.getElementById("theme-switch");
// Check for saved theme preference
const savedTheme = localStorage.getItem("theme");
if (savedTheme) {
document.body.classList.add(savedTheme);
themeSwitch.checked = savedTheme === "light-mode";
}
// Toggle theme on switch change
themeSwitch.addEventListener("change", () => {
if (themeSwitch.checked) {
document.body.classList.add("light-mode");
document.body.classList.remove("dark-mode");
localStorage.setItem("theme", "light-mode");
} else {
document.body.classList.add("dark-mode");
document.body.classList.remove("light-mode");
localStorage.setItem("theme", "dark-mode");
}
});
});
document.addEventListener("DOMContentLoaded", function () {
const menuToggle = document.querySelector(".hamburger-menu");
const navLinks = document.querySelector(".nav-links");
menuToggle.addEventListener("click", function () {
navLinks.classList.toggle("active");
});
});