forked from N-Shar-ma/FOSS-Weekend-Klox-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
js.js
27 lines (21 loc) · 709 Bytes
/
js.js
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
const header = document.querySelector("header");
const darkModeToggle = document.querySelector(".dark-mode-toggle");
darkModeToggle.addEventListener("click", toggleDarkMode);
function toggleDarkMode()
{
darkModeToggle.classList.toggle("dark");
document.querySelector("body").classList.toggle("dark");
}
const menuToggle = document.querySelector("[data-menu-toggle]");
menuToggle.addEventListener("click", toggleMenu);
function toggleMenu() {
header.classList.toggle("show-mobile");
}
const navLinks = document.querySelectorAll(".nav-link");
navLinks.forEach((navLink) => {
navLink.addEventListener("click", closeMobileMenu);
})
function closeMobileMenu()
{
header.classList.remove("show-mobile");
}