I basically have the same question as this guy: https://theme.co/apex/forum/t/collapsed-navigation-menu-closing-after-click-unless-its-a-sub-menu-heading/15070
But with a little twist.
For the mobile menu items that have children (submenu) I’d like to allow the initial click to open the submenu, but if that top-level item is clicked again I’d like for the menu to close and the page navigate to the #anchor that is set on that top-level menu item.
It should be easy to target the menu items that have submenus with the .menu-item-has-children class.
I’m using this code right now to make the menu collapse when menu items with one-page nav are clicked and it’s working great:
$(’.home .x-off-canvas .x-anchor’).on( “click touchstart”, function() {
if ($(this).attr(‘href’).indexOf(’#’) !== -1) {
$(’.x-off-canvas-close’).click();
}
});
I just need to add that extra bit of functionality for the menu items that have submenus.