I already used the js code from https://www.megamenu.com/documentation/close-menu-after-click/ but it doesn’t seem to work 🙁
Hi cyvan,
Please can you try this JavaScript instead?
/* Max Mega Menu
* Close the mobile menu as soon as a menu item is clicked */
jQuery(".max-mega-menu").on("after_mega_menu_init", function() {
jQuery("li.mega-menu-item:not(.mega-menu-item-has-children) > a.mega-menu-link").on('click', function(e) {
jQuery(".mega-menu-open").removeClass("mega-menu-open");
jQuery(".responsive-menu").css('display', '').removeClass('active');
});
});
Regards,
Tom
Hi Tom,
Thanks for your reply. It works perfectly. I needed to take care that the script runs from the footer. From the header it is not working, which caused a bit confusion to me.
Just a small glitch; when clicking contact, the page scrolls to the #contact-us section but also the submenu opens. Now the menu is not closing anymore. Any ideas how to handle this?
Warm regards,
Cornelis
-
This reply was modified 6 years, 6 months ago by
cvanbemmel.
Hi Cornells,
You could try this instead:
/* Max Mega Menu
* Close the mobile menu as soon as a menu item is clicked */
jQuery(".max-mega-menu").on("after_mega_menu_init", function() {
jQuery("li.mega-menu-item > a.mega-menu-link").on('click', function(e) {
jQuery(".mega-menu-open").removeClass("mega-menu-open");
jQuery(".responsive-menu").css('display', '').removeClass('active');
});
});
.. but it may become impossible to reveal the contents of the contact us sub menu (although clicking on the arrow may work)
Regards,
Tom