This code selects menu item links and a menu toggle element from the document using the `querySelector` method.

PHOTO EMBED

Wed Sep 20 2023 05:32:16 GMT+0000 (Coordinated Universal Time)

Saved by @riyadhbin

const menuItemLinks - document -querySelectorAl1(' .menu-item a');
const menuToggle - document.querySelector (' .bricks-mobile-menu-toggle")
                                                                                    
const handleclick = () => {
    menuToggle.click()
}

if (window.matchMedia(' (max-width: 768px) ').matches) {

      menuItemLinks.forEach(link =› {

          link.addEventListener('click', (event) => {
						handleClick();
          })
      })
}
content_copyCOPY