šŸŽ Help us shape Codewell into a better product for a chance to win one month of Codewell Pro →

  • Fiber Landing Page

    TRIPLE-ADE•8 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.