Skip to content

navbar.mjs

up2108272 edited this page May 8, 2024 · 2 revisions

navbar.mjs

Basic information

  • Sets functionality for navigation bar on the left side of all pages

function eventListeners()

function eventListeners() {
    let nav_toggle = document.querySelector("#open-nav-btn");
    nav = document.querySelector("#nav");

    nav_toggle.addEventListener("click", navBarToggle);
}
  • Allows js to interact with the html page

navBarToggle()

function navBarToggle(){
    if(showing === false) {
        nav.classList.add('nav-show');
        nav.classList.remove('nav-hide');
        showing = true;
        return;
    } 
    nav.classList.add('nav-hide');
    nav.classList.remove('nav-show');
    showing = false;
}
  • toggles whether the nav bar is displayed

Clone this wiki locally