Studio Daniel Gremme
Studio Daniel Gremme
document.addEventListener('click', function(event) { var mobileNav = document.querySelector('nav.laynav.mobile-nav'); var mobileNavButton = document.querySelector('.mobile-nav-button'); // Check if the click target is the mobile menu button or inside the mobile menu var isMobileNavButtonClicked = event.target === mobileNavButton || mobileNavButton.contains(event.target); var isInsideMobileNav = mobileNav.contains(event.target); // Close the mobile menu if it is active and the click is outside the menu or not the mobile menu button if (mobileNav.classList.contains('active') && !isInsideMobileNav && !isMobileNavButtonClicked) { mobileNav.classList.remove('active'); } });