In case anyone is interested, I think I managed to find a solution. Just had to add the following two lines of code just after the e.preventDefault();
line and before the _this.toggleClass( 'toggle-on' );
one:
container.find( '.dropdown-toggle.toggle-on' ).not( _this ).not( _this.parents( '.children, .sub-menu' ).prev( '.dropdown-toggle' ) ).removeClass( 'toggle-on' ).attr( 'aria-expanded', false );
container.find( '.children.toggled-on, .sub-menu.toggled-on' ).not( _this.next( '.children, .sub-menu' ) ).not( _this.parents( '.children, .sub-menu' ) ).removeClass( 'toggled-on' );
I don’t know if there’s a better way to do it, but this seems to work as I want.
Related Posts:
- Add Javascript to WordPress Menu
- Merge two separate WP menus into one in Mobile view
- Add class to menu ul with active child
- I am facing a problem with the navigation menu of my website
- Static page to one page- menu inactive items highlighted
- Adding toggle-able element after menu item
- WP Menu Rollover Nav Item and Effect DIV Elsewhere
- Cannot collapse a responsive menu in WordPress
- Add “onclick” option to header menu item
- calling JS to custom menu design
- Links in new menu don’t work
- Menu Details Output in Javascript [closed]
- Jquery dropdown menus working locally, but not in WordPress [duplicate]
- Split up wp_nav_menu with custom walker
- How to Add to Each Menu Link with link text to data-attr?
- Removing link ” from ” menu for some “links” without JS
- Multi Level Bootstrap Navigation Menu in WordPress
- Determine if a navigation item has children
- Bootstrap dropdown nav pills not working with wp_nav_menu()
- How to move parent li to end of child ul
- Links open only on new tab or window
- How to Create a Custom WordPress Navigation Menu with the Code?
- Custom Nav Walker sub-menu HTML construct
- jQuery cookie not working properly in wordpress
- Make compatible custom menu widget for Twitter Bootstrap
- How to display dynamic content in start_lvl function
- Add custom text to menu
- Menu styling for last menu item
- Disable automatig SVG tag from menu
- Replace menu permalink/hyperlink with only menu name/slug
- wp_nav_menu add some element to container
- Use wp_nav_menu to display ALL pages
- Third level navigation class
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- get_query_var(‘post_type’) not returning in a filter
- Find out if a page has no parent
- Replace menu links with # and add name to its li
- Navigation Menus Depth for specific menus
- wp_nav_menu() with multiple Class
- add span class and i tag inside wp_nav_menu link anchor tag
- Can’t include Language switch in Nav Menu
- Add within the output of
- Reuse a custom WordPress menu on another WordPress website
- How to dynamically populate a dropdown
- Is this format possible with a custom Nav Walker class?
- two different separate sections on the same site
- Add code to WordPress menu items by class
- How do you add a around the second level of a Menu?
- How can I add text to a single nav menu item?
- Alternative to wp_get_nav_menu_items?
- Using my WordPress menu on another platform
- How Do I Add Images To Main Navigation Menu
- Add a submenu to wp_nav_menu
- Hide menu from homepage
- remove menu items if user can’t read
- Adding numbers inside a span tag in nav menu [closed]
- WordPress Menu adds an unwanted slash before anchor
- How to automatically redirect to first item of second navigation level in a multi-level menu?
- Locking in navigation labels before changing title?
- How to Add support for sub-menu item description in wordpress?
- Blending Foundation’s Tabs with WordPress Nav Menu & Display Active Tab
- Editing the nav menu?
- Additional navigation bar in header
- Why is my navigation in my onepage not working?
- Navigation item – current date in url
- Hide a menu (navigation bar) on all posts
- Nav Menu: Theme Location not working
- How to remove empty line space in navigation menu?
- Is it possible to get_the_post_thumbnail (Featured Image) inside a sprintf function?
- Bootstrap Theme Migrated to WordPress
- Homepage Menu Link Won’t Function
- Bootstrap Nav Walker Sub Menu Image
- Creating navigation out of specific IDs and their children?
- Add active class to wp_nav_menu
- javascript i wrote not working, can’t figure out why [closed]
- Mobile menu not working – jQuery error?
- how to configure this type of menu
- show a hidden ul if li is active
- How can I make menu items into two seperate buttons with different functions?
- Header lists posts instead of showing primary nav menu
- Programmatically add a Navigation menu and menu items
- Site-wide tabs at WordPress website?
- Creating custom Menu for custom theme
- How to add class and span to
- Show Child of Parent Page including all other parents
- Show only second level menu items? [duplicate]
- Add item ONLY to the primairy navigation
- Image menu on responsive WordPress
- individual images as navigation design TwentyTen
- WordPress Navigation default output
- How to call either page name as the nav link or navigation title?
- How to get wordpress navigation to work
- How do I get my nav menu to show sub pages?
- How do I show a different secondary navigation menu for each section of my website?
- how to make a walker to this (in bootstrap, i try but not work)
- can’t add EVENT LISTENER to a element
- Site navigation sits unstyled for a second on page reload [closed]
- Changing when mobile menu is displayed
- Custom navigation / menu output (walker?)
- How can I only show one responsive menu on mobile devices?