Mobile toggle menu is not closing while clicking outside
-
Hello there,
Thanks in advance for the help!The main issue I’m facing with the mobile toggle menu is not closing while clicking outside of the menu item or outside of the menu.
I found a fix by searching your support threads but the main problem with this fix is when the menu has sub-menu items under a menu item, it closes without showing the submenu items when you again click on the toggle menu it shows the menu again with the submenu items opened.
Here’s the code from the thread’s support I foundwp_enqueue_script('jquery'); function custom_script() { ?> <script type="text/javascript"> jQuery(document).ready(function($) { $( document ).click( function( e ){ if( 'fas fa-align-justify' != $( e.target ).attr( 'class') ) { var id = $( '.elementor-widget-navigation-menu' ).data( 'id' ); if( window.matchMedia( "( max-width: 767px )" ).matches ){ var $this = $( '.elementor-element-' + id + ' .hfe-nav-menu-icon' ); var $selector = $this.parent().next(); if ( $this.parent().hasClass( 'hfe-active-menu' ) ) { var layout = $( '.elementor-element-' + id + ' .hfe-nav-menu' ).data( 'layout' ); var full_width = $selector.data( 'full-width' ); var toggle_icon = $( '.elementor-element-' + id + ' nav' ).data( 'toggle-icon' ); $( '.elementor-element-' + id).find( '.hfe-nav-menu-icon' ).html( toggle_icon ); $this.parent().removeClass( 'hfe-active-menu' ); $this.parent().attr( 'aria-expanded', 'false' ); if ( 'yes' == full_width ){ $this.removeClass( 'hfe-active-menu-full-width' ); $selector.css( 'width', 'auto' ); $selector.css( 'left', '0' ); $selector.css( 'z-index', '0' ); } } } } }); }); </script> <?php } add_action( 'wp_footer', 'custom_script' );
- This topic was modified 2 years, 8 months ago by .
- This topic was modified 2 years, 8 months ago by .
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Mobile toggle menu is not closing while clicking outside’ is closed to new replies.