Problems with mobile menu and anchor links

Hello,

I have a link in the mobile menu which points to a section inside the page.
When I click it - it doesn’t close the mobile menu.
I have tried this code, and the event is not getting called when on the same page:

jQuery(document).ready(function($){
$(’.menu-item a’).click(function(){
$(’.x-nav-wrap.mobile’).removeClass(‘in’);
});
});

The code was mentioned here: https://theme.co/apex/forums/topic/closing-mobile-menu-on-select/

Thank you
Yaron

Hello Yaron,

Please use this instead

jQuery(document).ready(function($){
$('.menu-item a').click(function(){
$('.x-nav-wrap.mobile.collapse').removeClass('in');
});
});

Hope it helps

Hello Joao,

Thank you for your reply,

It doesn’t work. If I am on the same page - there is no event.
I also tried catching all click events on the page:
‘window.onclick = function(e) { console.log(e.target);};’
and there is not event

Thank you
Yaron

Hi Yaron,

Please try this:

jQuery(function($){
  
  $('.mobile .x-nav a').on('touchend click', function(){
    $('.x-btn-navbar').click();
  });

});

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.