• Fiber Landing Page

    TRIPLE-ADE2 months ago

    Adding an active class using toggle and removing it


    let hamburger = document.querySelector('.hamburger');
    let navMenu = document.querySelector('.navbar-links');

    hamburger.addEventListener('click', function () {
      hamburger.classList.toggle("active");
      navMenu.classList.toggle("active");
    })

    document.querySelectorAll(".nav-link").forEach(e => e.addEventListener('click', () => {
      hamburger.classList.remove('active');
      navMenu.classList.remove("active");
    }))

    • 1
No comments on this solution yet.
Be first to post.
Join Our Slack Channel
Chat and discuss solutions with a growing community of developers.