Fixed Menu on mobile: Menu not closing on selection

Hi,

I use

    @media (max-width: 979px) {
.x-navbar-fixed-top {
position: fixed !important;
}
}

to have a fixed menu on mobile. But everytime you click on some of the items it stays opened/isn’t collapsing. It only collapses when clicking the burger icon. I tried various JavaScript solutions from the forum but nothing seems to work. Any idea?

Can’t show page because it’s a local staging, can’t use it in prod like this. Thanks!

Hi Alexander.

Thank you for reaching out to us. You can try adding the following code in the Theme Options > JS:

jQuery(function($) {
  $('.mobile .x-nav li:not(.menu-item-has-children) > a').on('touchend click', function(){
    $('.x-btn-navbar').click();
  });

  $('.x-sub-toggle').on('touchstart click', function(e){
    e.preventDefault();
    $(this).toggleClass('x-active').closest('li').toggleClass('x-active');
  });
});

Don’t forget to clear all caches including your browser’s cache after adding the code. Let us know how this goes!

Works perfect. Thank you very much!

You’re welcome!
We’re glad @Nabeel were able to help you out.

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