website/static/js/mobile-navbar.js

23 lines
491 B
JavaScript
Raw Normal View History

2024-12-15 08:09:10 +01:00
const burger = document.querySelector(".hamburger")
const links = document.querySelector(".links")
const body = document.querySelector("body")
let shown = false
burger.addEventListener("click", (e) => {
e.preventDefault()
if (!shown) {
links.style.display = "flex"
body.classList.add("disable-scroll")
burger.textContent = "x"
} else {
links.style.display = "none"
body.classList.remove("disable-scroll")
burger.textContent = "☰"
}
shown = !shown
})