Subscribe On YouTube

Join other subscribers and enjoy other Divi video tutorials!

How To Collapse Divi Mobile Menu Submenus

Nelson Miller Profile Orange
In this tutorial I will show you the best and easiest way to collapse the Divi mobile menu submenus and add toggle icons that look great!

▶️ Please watch the video above to get all the exciting details! 👆

1. Add Some jQuery To Collapse The Divi Mobile Menu Submenus

The idea here is to change the Divi mobile menu from a boring, expanded list to a beautiful compact list. We can do this by adding some jQuery and CSS code. This will not only collapse the mobile Divi menu submenu, but also will add some nice toggles that can be used to indicate to the user that there are more items to show and where to click. This tutorial comes in two parts, one for each type of code. Both of them work together and both are needed to make it work.

Where To Paste The jQuery Code

1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the jQuery tab in the custom code window in the Divi Visual Builder.

2. Child Theme
If you are using a child theme, paste this code into the scripts.js file (don't forget to remove the <script> tags at the beginning and end). If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.

3. Divi Theme Options Integration
Otherwise, paste this code in your Divi>Theme Options>Integrations tab in the "Add code to the < head > of your blog" code area.

If you need help understanding where to paste the code, please check out our complete guide about where to add custom code In Divi.

<script >
    jQuery(function($) {
        $(document).ready(function() {
            $("body ul.et_mobile_menu li.menu-item-has-children, body ul.et_mobile_menu  li.page_item_has_children").append('<a href="#" class="mobile-toggle"></a>');
            $('ul.et_mobile_menu li.menu-item-has-children .mobile-toggle, ul.et_mobile_menu li.page_item_has_children .mobile-toggle').click(function(event) {
                event.preventDefault();
                $(this).parent('li').toggleClass('dt-open');
                $(this).parent('li').find('ul.children').first().toggleClass('visible');
                $(this).parent('li').find('ul.sub-menu').first().toggleClass('visible');
            });
            iconFINAL = 'P';
            $('body ul.et_mobile_menu li.menu-item-has-children, body ul.et_mobile_menu li.page_item_has_children').attr('data-icon', iconFINAL);
            $('.mobile-toggle').on('mouseover', function() {
                $(this).parent().addClass('is-hover');
            }).on('mouseout', function() {
                $(this).parent().removeClass('is-hover');
            })
        });
    }); 
</script>

2. Add Some CSS To Collapse The Divi Mobile Menu Submenus

The next step is to add the corresponding CSS code. This code works alongside the jQuery, and together they create the Divi mobile menu collapsed effect.

Where To Paste The CSS Code

1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the CSS tab in the custom code window in the Divi Visual Builder.

2. Child Theme
If you are using a child theme, paste this code into the style.css file. If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.

3. Divi Theme Options Integration
Otherwise, paste this code in your Divi>Theme Options>Custom CSS code box.

If you need help understanding where to paste the code, please check out our complete guide about where to add custom code In Divi.

/*change hamburger icon to x when mobile menu is open*/

#et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before,
.et_pb_module.et_pb_menu .et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before {
	content: '\4d';
}


/*adjust the new toggle element which is added via jQuery*/

ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,
ul.et_mobile_menu li.page_item_has_children .mobile-toggle,
.et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,
.et-db #et-boc .et-l ul.et_mobile_menu li.page_item_has_children .mobile-toggle {
	width: 44px;
	height: 100%;
	padding: 0px !important;
	max-height: 44px;
	border: none;
	position: absolute;
	right: 0px;
	top: 0px;
	z-index: 999;
	background-color: transparent;
}


/*some code to keep everyting positioned properly*/

ul.et_mobile_menu>li.menu-item-has-children,
ul.et_mobile_menu>li.page_item_has_children,
ul.et_mobile_menu>li.menu-item-has-children .sub-menu li.menu-item-has-children,
.et-db #et-boc .et-l ul.et_mobile_menu>li.menu-item-has-children,
.et-db #et-boc .et-l ul.et_mobile_menu>li.page_item_has_children,
.et-db #et-boc .et-l ul.et_mobile_menu>li.menu-item-has-children .sub-menu li.menu-item-has-children {
	position: relative;
}


/*remove default background color from menu items that have children*/

.et_mobile_menu .menu-item-has-children>a,
.et-db #et-boc .et-l .et_mobile_menu .menu-item-has-children>a {
	background-color: transparent;
}


/*hide the submenu by default*/

ul.et_mobile_menu .menu-item-has-children .sub-menu,
#main-header ul.et_mobile_menu .menu-item-has-children .sub-menu,
.et-db #et-boc .et-l ul.et_mobile_menu .menu-item-has-children .sub-menu,
.et-db #main-header ul.et_mobile_menu .menu-item-has-children .sub-menu {
	display: none !important;
	visibility: hidden !important;
}


/*show the submenu when toggled open*/

ul.et_mobile_menu .menu-item-has-children .sub-menu.visible,
#main-header ul.et_mobile_menu .menu-item-has-children .sub-menu.visible,
.et-db #et-boc .et-l ul.et_mobile_menu .menu-item-has-children .sub-menu.visible,
.et-db #main-header ul.et_mobile_menu .menu-item-has-children .sub-menu.visible {
	display: block !important;
	visibility: visible !important;
}


/*adjust the toggle icon position and transparency*/

ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,
.et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle {
	text-align: center;
	opacity: 1;
}


/*submenu toggle icon when closed*/

ul.et_mobile_menu li.menu-item-has-children .mobile-toggle::after,
.et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle::after {
	top: 10px;
	position: relative;
	font-family: "ETModules";
	content: '\33';
	color: #00d263;
	background: #f0f3f6;
	border-radius: 50%;
	padding: 3px;
}


/*submenu toggle icon when open*/

ul.et_mobile_menu li.menu-item-has-children.dt-open>.mobile-toggle::after,
.et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children.dt-open>.mobile-toggle::after {
	content: '\32';
}


/*add point on top of the menu submenu dropdown*/

.et_pb_menu_0.et_pb_menu .et_mobile_menu:after {
	position: absolute;
	right: 5%;
	margin-left: -20px;
	top: -14px;
	width: 0;
	height: 0;
	content: '';
	border-left: 20px solid transparent;
	border-right: 20px solid transparent;
	border-bottom: 20px solid #ffffff;
}


/*adjust the position of the hamburger menu*/

.mobile_menu_bar {
	position: relative;
	display: block;
	bottom: 10px;
	line-height: 0;
}


/*force the background color and add a rounded border*/

.et_pb_menu_0.et_pb_menu .et_mobile_menu,
.et_pb_menu_0.et_pb_menu .et_mobile_menu ul {
	background-color: #ffffff!important;
	border-radius: 10px;
}

As you can see, each of the snippets are labeled. This does a good job of explaining what each one does. As always, feel free to customize anything like colors and sizes. 

Option: Use Parent Menu Item As Toggle For Submenu

This seems to be a big question in the comment section, so I am adding the answer here. If you want to essentially remove the parent menu item link and use it as the same toggle mechanism as the dropdown icon. Instead of linking to that page, it will be used only as placeholder text and a toggle.

<script>
jQuery(document).ready(function(){
jQuery(".et_mobile_menu .menu-item-has-children a").each(function(){
jQuery(this).click(function(event){
event.preventDefault();
jQuery(".et_mobile_menu").toggleClass("pa-block");

jQuery(this).siblings("ul").toggleClass("pa-submenu");
})
})
})
</script>
.et_mobile_menu .menu-item-has-children .sub-menu{
display: none !important;
}

.pa-block{
display: block !important;
height: fit-content !important;
padding-top: 0 !important;
margin-top: 0 !important;
padding: 5% !important;
margin-bottom: 0 !important;
margin-top: 0 !important;
}

.et_mobile_menu .menu-item-has-children .pa-submenu{
display: block !important;
}

.opened .et_mobile_menu{
height: fit-content !important;
padding: 5% !important;
}


ul.et_mobile_menu li.menu-item-has-children .mobile-toggle, .et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle{
    	    text-align: right;
    	    width: 100%;
    }

Do It With A Setting!

Make life easier and use the Divi Responsive Helper instead, the ultimate Divi responsive toolkit with awesome features and settings to help make your website look and work great on all devices!

Divi Responsive Helper Plugin by Pee Aye Creative

Related Tutorials To Help With The Divi Mobile Menu

In our video and tutorial, we are using some code to help the mobile menu look better. This all comes from our Divi Menu tutorial series! I recommend checking out those other tutorials for lots of helpful and fun stuff!

Subscribe For More Things Like This!

At the start of each month, we send out a recap newsletter from the month before with family news, Divi news, our latest tutorials, and product news. Occasionally, if the news is too exciting to wait, we will send out another email separate from the monthly newsletter. That’s what you get when you subscribe, and of course you can unsubscribe if you are no longer interested!

Blog Post Optin
Divi Logo (2)

Shop Our Divi Products

Plugins • Courses • Templates

Visit The Shop

Featured Products

Asset 4

New! Trail Guides

Follow a series of blog posts carefully arranged around a specific topic or goal! Keep track of your progress by marking posts completed, just like a free course!

View Trial Guides

Divi Trail Committee Membership badge with map design

Join The Trail Committee!

Show support for our ongoing work creating community resources at Pee-Aye Creative and enjoy exclusive member perks in return.

Learn More

Divi Tutorials On YouTube

Our videos have views! Join subscribers and enjoy over video tutorials!

Visit Our Channel

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy

398 Comments

Comments By Members

These comments are highlighted because they were posted by fans who have a membership on this site.

  1. Tim McCandless <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Hi there — this is a question for the collapsing menu that’s ALSO turned on by the Divi Responsive Helper (which I’m using). The toggles function properly, but when I hover over the toggles, the accompanying link color reverts to the desktop text color, and not the color of the text in the actual mobile menu. In this case, I need the text to be/stay white (the dropdown mobile menu has a dark background color) and it reverts back to the darker color of the text in the desktop menu. Any suggestions? I can send you a link to the staging site I’m working on — just let me know an email address or alternative to that (I can’t post on a public forum.)
    Thanks!

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Tim!

      You can add the staging site link in the comment. We’ll keep the comment private and won’t display it publically.

      Reply
  2. Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Hi Simone!

    I can see the following script is also added which is not from our guide and causing the conflict with our codes. Please remove it and see if it helps.

    setTimeout(function(){
    jQuery(document).ready(function(){
    jQuery(‘li.menu-item-has-children’).click(function(){
    if(jQuery(‘li.menu-item-has-children’).hasClass(‘dt-open’)){
    jQuery(‘li.menu-item-has-children’).removeClass(‘dt-open’);
    jQuery(‘li.menu-item-has-children .sub-menu’).removeClass(‘visible’);
    jQuery(this).addClass(‘dt-open’);
    jQuery(this).find(‘.sub-menu’).addClass(‘visible’);
    }
    });
    });
    },500);

    Reply
  3. Daphne Talbot <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Hi Nelson, I’ve used this on several sites. Super easy to implement. Love it.

    On the site I’m moving over to Divi today, the dropdown menu’s parent item is not a link but. In the menu I have the link set as #.

    The site is https://awemoneyandme.com/.
    The dev site is https://tscpreview.net/.

    This works great on the desktop. On mobile, if the parent item is clicked the child menu items stay closed, the page reloads.

    For example:
    Workshops (this has no page but in the menu has a # for the link)
    Money and Me
    Lifestages

    Any suggestions on how to handle the mobile menu so that when Workshops is clicked it opens the menu instead of reloading the page?

    Thanks!

    Reply
  4. ECDJ <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Seems like the indetation/spacing on the submenu items is not working showing on my site: https://www.o21.nu/

    Also the hamburger icon seems higher than before, not aligning with the search icon on iPad.

    Any idea why? Got a fix?

    Reply
    • Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

      I think you have some other CSS on your site, for example I see a margin of 10px that is causing that

      .mobile_menu_bar {
      position: relative;
      display: block;
      bottom: 10px;
      line-height: 0;
      }

      and your submenu items have the same padding

      .et_mobile_menu li a {
      border-bottom: 1px solid rgba(0,0,0,.03);
      color: #666;
      padding: 10px 5%;
      display: block;
      }

      so you could change that if you want by targeting them with .et_mobile_menu li ul li a

      Reply
      • ECDJ <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

        Thanks, it was actually a CSS code from you; changing the layout of the submenu, just changed it to only target desktop 😉

Comments By Others

  1. Rachel Batista

    Hi there! First off, thank you sooooo much for this! I followed this code to a T, and still am getting the toggle open icon to not show up correctly. Can you help?

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Rachel!

      Can you please disable the cache plugin and clear the Divi cache? If it still doesn’t work, please share the URL of the page.

      Reply
  2. Marianna

    Hi! Thank you so much for this solution. Unfortunately, it doesn’t quite work for me.
    Here’s the link: https://odderbeing.com
    As you can see, while the submenus *are* collapsed, there is no icon visible to make them visible. I double-checked the CSS and the ‘/32’ and ‘/33’ are present, including the slash. I’m not sure why this happens, can you point me in the right direction?

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Marianna!

      I can see the first script is missing. Please add the script in the Integration tab in the Theme options and see if it helps.

      Reply
  3. Justin

    Hello! Using the Divi Responsive Helper and this code. On mobile the submenus are not toggling open. Cleared cache, tried different browsers, incognito window, etc. Any thoughts on what might be causing this?

    I jumped to this solution because the arrows were showing up as 33 and 32 in the drop down. Tried all your suggestions to troubleshoot on another video without any luck.

    I appreciate you help!

    Reply
  4. PopDitital

    Thank you for good article.
    I would like to ark you 1 more question.
    How to change color of icon and icon background.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi there!

      Can you please clarify which icon you are referring to? the hamburger icon or the toggle icon?

      Reply
  5. Jenny

    thank you for your tutorial, I’ve been wanting to do this on my site for a long time! However I’m not very good with code 😅 Luckily I found a plugin that does it automatically without any configuration! I put the link here for those who might be interested.: https://www.elegantthemes.com/marketplace/divi-collapse-submenu/

    Reply
  6. Bertrand Lequeux

    Hello Nelson,
    I’m using this tutorial and it works perfectly, thank you ! Unfortunately, it is not compatible with the “Speed Optimizer” plugin from siteGround, one of the most important plugins in terms of speed optimization. In fact, when I activate the plugin, the code stops working, which is really frustrating.
    Have you heard about this problem, have you any suggestions to fix it?
    Thank you so much !

    Reply
  7. John Cowell

    This works great on my site. Thank you

    Just one thing i’ve noticed that I have some child pages (e.g Curriculum, located under Education) which should be made clickable but it’s going to a # instead.

    Link: https://shorturl.at/kpd0B

    How can I resolve this?

    Thanks!

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi John!

      I have checked and the Curriculum is redirecting to the page. It seems you had added the 2nd script which made the links non-clickable. Now the script is removed and everything seems to be working fine.

      Reply
  8. yann vautrin

    Hiya Nelson, again thanks for the great work!

    on my website (mobile version) vchurch.us , when I click on the burger, it shows menu with toggle icons for submenus, but when i click on the icon, submenus don’t show…

    Any idea ?

    Thanks for your help!

    Reply
      • Yann Vautrin

        Hiya Hemant!

        Thanks for your assistance!

        All Plugins deactivated on the test website…still facing the same issue…

      • Yann Vautrin

        Code is now on our test server… facing the same issue…
        https://test.vchurch.us/
        thanks for your help !

  9. Yann Vautrin

    Hiya Nelson!

    Thanks for all your work, it really helps making websites better!

    I just tried to setup your snippets for my website, I now have a collapsed menu on mobile with the toggle icons for submenus, when I click on the toggle icon, i changes from arrow down to arrow up, but submenus do not show….

    any chance to have a look and tell me what I did wrong ?

    Here is the web site : https://vchurch.us

    Thanks for your help !

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Yann!

      I can see that the code is removed now. Can you please implement the code again so that I can check further?

      Reply
      • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

        In that case, remote access is needed to check the issue further. I would suggest you to contact Elegant themes support and ask them to check the issue remotely.

      • Yann Vautrin

        Hiya, I have deactivated all plugins on test website…still same issue….

      • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

        It seems the menu is working fine on the initial load. Somehow, the script is blocking aftewards. Can you please disable all the plugins and check again?

      • Yann Vautrin

        Hiya Nelson, I had to remove the code from Production site as it was not working, if you have time to take a look at our Dev website… I am facing the same issue…

        https://test.vchurch.us/

        thanks agian for your time!

      • Yann Vautrin

        Hiya Hemant!
        Thanks for your reply, I just put the code back, as I want to find out the issue!
        If you can please take a look!

        Thanks for your help!

  10. fiqi

    Hi Nelson, thanks for creating this guide. I have a question, I have make the submenu collapse, but I need to click the arrow to show the submenu, I need the parent link can be clicked too to show the submenu, now when I click the parent, the mobile navbar is closed. Any suggestion? Thanks in advance.

    Reply
  11. Jeff Daniels

    This is great. Thank you!!

    Can we force only having one parent category open at a time?

    Reply
  12. Eric from SF

    Thank you for the great content! I had an issue where clicking the main heading (the heading that contains the children) would close the nav rather than toggling the content. My version modifies the CSS to expand and contract using the Heading and the Icon as a toggle.

    /*adjust the new toggle element which is added via jQuery*/
    ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,
    ul.et_mobile_menu li.page_item_has_children .mobile-toggle,
    .et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,
    .et-db #et-boc .et-l ul.et_mobile_menu li.page_item_has_children .mobile-toggle {
    width: 100%; /* was 44px */
    etc. } and:
    /*adjust the toggle icon position and transparency*/
    ul.et_mobile_menu li.menu-item-has-children .mobile-toggle,
    .et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle {
    text-align: right;
    etc.}

    Reply
  13. Luca Rimediotti

    Hello,

    I used your guide to modify the menu on my site, in doing so I saw that the items that open/close the submenu are not clickable.
    In the sense that those menu items only have the toggle function but they no longer open the assigned page.

    How can I modify those menu items so that they can open the assigned url (like text) and also open the submenu toggle (like icon).

    I thank you for your work!

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Luca!

      We have provided both the options above. Please use the first script and not the second one.

      Hope it helps!

      Reply
  14. Jessica

    Thank you for the incredibly easy fix! I have your awesome responsive helper app, but I was seeking a solution I can simply add via CSS and this did the trick.

    Reply
  15. Rebecca

    Hello,

    I’m not seeing the toggle icon on sub menus under submenus. Please could you have a look and see what I’m doing wrong. The site is https://www.axfordinteriors.co.uk/, please click on About then Locations. Locations is not showing the toggle.

    Thank you!

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Rebecca!

      Please try adding the following code and see if it helps:

      ul.et_mobile_menu li.menu-item-has-children .mobile-toggle:after, .et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle:after {
      display: inline;
      }

      Reply
      • Rebecca

        This works! Thank you so much.

  16. Klaus

    Hi Nelson,

    first of all, thanks for your code and your work.

    I use youre code on one site, but the toggle (+) signs are not shown on the start page.
    On other sites, it works fine.
    Do you have any idea?

    thansk a lot, Klaus

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Klaus!

      Can you share the URL of the page so that I can investigate further?

      Reply
  17. Amber Beardmore

    Hi there!

    I used the additional code to Use the Parent Menu Item As Toggle For Submenu but now when you click on the parent item and the submenu opens, you can’t click on any of the submenu pages.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Amber!

      It seems to be an overlapping issue on the submenu. Can you share the page URL to inspect further?

      Reply
      • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

        I have checked and the sub-menu is clickable on my end. Can you try using another browser and see if it helps?

      • Amber Beardmore

        Haus820.com – I had to remove the CSS & Javascript code that makes the parent a clickable toggle because our users weren’t able to click the sub-menu items. Do you need me to add the code back to re-create the error?

  18. Lasse

    Hi Peeaye´s 🙂

    Great tut and it works perfect1

    But: Is there a way that the “parent” link is not bold?

    I have both parent links with children under, and links with no children. And the parent ones are bold – it lookes kind a messy in the dropdown.

    Hope im clear – from Denmark, so mayby my gramma is “funny” 😀

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Lasse!

      Please add the following code and see if it helps:

      .et_mobile_menu .menu-item-has-children>a{
      font-weight: 400 !important;
      }

      Change the font-weight value as per your requirement.

      Reply
  19. Tasha

    Just wanted to see if you had a code that could close this menu if a person clicks outside the menu area, without having to scroll all the way back up on the menu.

    Reply
  20. Marek K

    Hello, I have a litte weird question. How to make the same menu work also on dekstop menu? I m currently working on website, where I have side slide menu and I want to work it also there but as hard I try, I cannot make it work also on desktop.

    Reply
  21. Daniel T

    I’m a long time fan of your products as well as this tutorial. I’ve just noticed something though that I was hoping you may have a solution for. On iPads (tested 6-10) in vertical orientation, the hamburger menu shows, but the expanding arrows do not, so users cannot see the child items in them and clicking only opens the parent page. Perhaps the .et_mobile_menu class isn’t being invoked at those dimensions. Here’s the site I’m working on where I noticed this: https://dev.concretecountertopinstitute.com

    Any help would be greatly appreciated!!! Thanks so much!

    Reply
      • Daniel Trimpey

        That solved it, thanks!!!!!!!!!

      • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

        Hi Daniel!

        I have checked the console errors and can see that jQuery is getting blocked by the rocket loader feature of Cloudflare. Try deactivating the option and see if it helps.

  22. Florencia

    Hi Nelson! I’ve been using this code on many sites and I never had an issue until now. Strangely, everything works perfectly on my site pages but on posts (either built in or custom) it doesn’t. The toggle icons are just not there. I’ve been trying to troubleshoot for a while and even checked with Divi as I’m using the same global header for both pages and posts but so far no luck finding the answer. If someone in your team could take a look, would really appreciate it!

    Reply
  23. JODEY CORNWALL

    Hi I have set up the menu as per your instructions it all looks great only have one small issue it now says Menu above menu in the text and has created a section section

    Reply
  24. Miguel Zavala

    Hello, I’ve been trying but I don’t get the buttons on mobile, but they do on the web when I reduce to mobile size.

    I can’t get the buttons to show the submenus

    http://www.intitrek.pe

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Miguel!

      I’m able to replicate the issue on mobile devices. However, nothing can be seen while inspecting the page. Try disabling all the plugins and check again.

      Reply
      • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

        Hi Florencia!

        Thank you for sharing the plugin with us. We’ll test the customization with the plugin for the issue.

      • Florencia Daniela Doyharzabal

        I had the exact same issue and I think I found the culprit: ACF by WP Engine. Kind of a bummer since I have all my custom posts and fields created with it. I wonder if there’s anything that could be tweaked in the jquery or css code since just thinking about getting rid of ACF at this point makes me cry. Anyway, this is probably too much to ask I know but just thought I’d share my experience!

  25. Yen

    Hi!
    Can you please tell me how can I get the top right corner arrow and the X button removed?
    Thanks in advance.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Yen!

      I’m not able to understand which arrow you’re referring to. Can you please share some more details?

      Reply
  26. Andreas

    hey, thanks for providing such a function. I translate with google, hope you understand everything.

    unfortunately I have a problem. The “collaps mobile menu” does not load every time. from time to time only the categories without sub-items and without arrows are displayed.

    It just worked for a while, but then I updated the page and then it didn’t work again.

    please check my page:
    happyshrimp.de

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Andreas!

      I’m not able to access the page due to the maintenance mode plugin enabled. However, please try clearing the plugin cache or even disable the cache plugin and check again.

      Let me know if it helps!

      Reply
  27. Simone

    Hi Nelson,

    I’ve been using these menu tutorials for a while and they always worked perfectly! I noticed a few days ago that the toggle on mobile was gone. I’ve checked all the codes and even deleted them and added them again. Afterwards the toggle is back again, but now when I open the first submenu, all the submenu’s underneath that one are open as well and I’m not able to close anymore. The toggles stopped working. Do you have any idea what my problem would may be?

    My link is: https://travelwithsimone.com/

    Reply
  28. Glenn Skorko

    Hi Nelson,

    Thanks for sharing your solution. There are a lot of people looking for one that works dependably and your original CSS and jQuery is perfect!

    I tried adding the optional CSS and code and the menu was blank. I solved that by adding display:block to your .opened class and everything became visible. Unfortunately the links are dead on the sub-items in the menu in addition to their parent buttons. I believe there may also be an issue with opening and closing the menu with the optional add on.

    I had to remove the option but would love to use it if you circle back to it and get it working.

    Thanks again for a great solution Nelson.

    Glenn

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Glenn!

      I have checked the code and there is no issue with it. The code must get conflicted with any other code on your site. If you still need help regarding it, please share the URL of the page to investigate further.

      Reply
  29. Tom

    Hi! First of all: Awesome blog, so helpful in many aspects.

    I lust applied your code. Works like a charm. Is there a way to unfold the next level also when clicking on the text? Right now, it only works when clicking on the icon….

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Tom!

      We have provided the codes to open the submenu when clicked on the parent menu items. Please follow the script and CSS under Option: Use Parent Menu Item As Toggle For Submenu heading in the guide.

      Reply
  30. Jillian

    Thank you for this tutorial but I am having 3 issues:

    1. When I click the parent menu item instead of the icon it closes the whole menu.

    2. I changed the color of the toggle in the css but it does not reflect on the menu in any browser.

    3. I have sub-sub menus and they are automatically opened with the parent it clicked, rather than allowing a user to open them via the toggle.

    I have cleared cache in divi and and my browser and have tested in safari, firefox and chrome. Please help!

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Jillian!

      Can you please share the URL of the page so that I can check further?

      Reply
  31. Bhanu

    Hello,

    Thanks for the article, I have implemented the above code and it was fine, but when I create a child theme, the two icons are showing but on the main theme showing only one icon.

    Please suggest.

    Reply
  32. Romain

    Hello Nelson,

    I don’t know how you manage to provide such a lasting support for a free tutorial. You are really a great help for the DIVI community. Thank you so much.
    Well I’m asking for your help too with a small question about a problem with this tutorial : child menu items are not clickable

    https://artbatiz.fr/

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Romain!

      I have checked the page and the submenu items are working fine now. Is the the issue resolved now?

      Reply
  33. conrado

    Hello Nelson I apply the code for Use Parent Menu Item As Toggle For Submenu, and works great thanks for that but I have several menus on my site and I like to Appli just in #mobil_menu1 I edit the jquery and also the CSS but is still working in all the site now I use media query because I using also the tutorial for the widget menu, so can you help me width that?

    Reply
  34. Kai

    Hi there, is there a solution for submenu’s under submenu’s. It doesn’t seem to work like with this code.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Kai!

      The submenu under the submenu’s should work fine. Can you please share the URL of the page so that I can check further?

      Reply
  35. Adrian Wirth

    Hi Nelson,

    Thank your for supporting me and the divi nation with your well explained and useful tutorial – great job!

    Also this mobile-menu coding works (almost) perfectly! But I have one issue: if the parent item is clicked instead of the arrow on the right side then the hamburger menu will close. How can I avoid this?

    URL: https://bsvweinfelden.ch/wordpress/

    Thanks for your help
    Adrian

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Adrian!

      I have checked the issue on “Mannschaften” menu item and not able to replicate the issue. The toggle is working fine when clicking on the menu item. Is the issue resolved?

      Reply
  36. Jessica

    What an incredible time saver. You are fantastic!!

    Reply
  37. Sean Wilkins

    I think this was asked before but never answered on thread. Is it possible to have the sub-menu’s be animated slowly just like the main mobile menu on click?

    thanks

    -sean

    Reply
  38. Oriana

    I freshly copy and pasted the JQuery and CSS just now, but my site on mobile doesn’t have an arrow you can click on in order to see the submenu items.

    Is there something I did wrong?

    Site: https://consumerenergysolutions.com/

    Thanks!

    Reply
    • Spencer

      I am having the exact same problem. I have actually used this code multiple times in the past. I came back to copy it for a new site and the dropdown is there on desktop, but not on tablet or mobile breakpoints. I even copied & pasted it three times and still not having any luck.

      Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Oriana!

      I’m not able to find the CSS code in the source code. Please make sure it is added properly.

      Reply
  39. Maik

    Hi Nelson, great work! Can you tell how to adjust the toggle speed to get a smooth transition? CSS Transition is not working on display: none; element, so it has to be adjusted in the java code adding time and easing somewhere?

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      HI Maik!

      I’m afraid changing the transition of the toggle sub menu needs hard customization. Yes, it can be done using JS. We’ll check further and update the guide. Stay tuned!

      Reply
  40. Echo

    Love this tut, thank you. How would I customize your JS so that I could add a sexy slide to the toggle? This toggle is such a jerky motion downward.

    Reply
  41. Juanma

    Hola Nelson,
    I have had this code working for a long time, but I have always tried to tweak it so that the Click on the word that accompanies the arrow works, but I have not succeeded.
    Do you have any idea how to fix it?
    Thank you so much!

    The website is https://strands.com

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Juanma!

      Please add the following code for the fix:

      ul.et_mobile_menu li.menu-item-has-children .mobile-toggle, .et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle{
      text-align: right;
      width: 100%;
      }

      Let me know if it helps!

      Reply
      • Juanma

        Hemant, thank you very much.
        It works perfectly!!!
        I had not thought that the solution could be in the css and I had been fighting with the js.

        Thanks again

  42. Marcel

    Works perfectly and this saved me so much time. It would have taken me forever to figure this out. Thank you so much!!!

    Reply
  43. Boris

    Hello,

    First thanks for the well explained and useful tutorial – great job.

    I have only one problem. I wrote all the comments and tried everything nut nothing helped. At the moment the code for Use Parent Menu Item As Toggle For Submenu is not added as it doesn’t work.

    The problem is that when I expand the submenus and click on them it doesn’t open the link. Instead it only changes the close menu icon back to hamburger. It even doesn’t closes the menu.

    This i s the web page: https://investinbansko.com/

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Boris!

      We have updated the code now. Please copy the updated code from above. The parent menu item should expand fine now on click.

      Reply
  44. Maurice

    Hi Nelson,

    thanks for the wonderful code! I implemented it on our site https://fsmed-muenster.de – works great under Chrome/Edge but under Firefox I can’t get the icons for expanding and collapsing the sub menus to appear … we are also using W3 Total Cache, but after deactivating the plugin you still have to refresh the site every single time to get the icons to appear – do you know any solution to this?

    Best regards
    Maurice

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Maurice!

      I have checked the page in Firefox and not able to replicate the issue. Can you please try disabling the minifying and combine JS and CSS options in the cache plugin and check again?

      Reply
  45. Payal Ahuja

    Hi Nelson, thank you for this tutorial. It is great and really helpful, after searching for the solution on the internet for 2 hours I found it and I love it.

    But I am facing an issue which is, whenever I open my website on mobile by default this menu is expending (opening without clicking)

    Could you please help me?

    Reply
  46. Francesco

    Hello and thank you for the tutorial.
    I applied the directions and managed to get the result I wanted. However, I noticed that it is only applied to the first submenu level.
    In fact, if there is a second submenu level, the rule does not apply and the menu then becomes very long.
    Could you help me so that the second level is also closed and only opens on click?

    Thank you.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Francesco!

      Can you please share the URL of the page so that I can check further?

      Reply
  47. Patrick Sweede

    The tutorial doesn’t work when menus contains 2 or more levels…….

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Patrick!

      Can you please share the URL of the page so that I can check further?

      Reply
  48. Richard

    Hi, thanks for this helpful tutorial!

    Is there any way to collapse the sub-sub menus? Parent and sub menu collapses perfectly, but we have 3 levels in our menu, the 3rd level does not collapse 🙁

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Richard!

      The code works fine with every level of the mobile menu. Maybe the menu you’re using is customized in some way, could you please provide the URL of the page for me to investigate further?

      Reply
  49. Emaux

    Really helpful tutorial!

    I have only one problem, we have menu – sub menu and “sub-sub-menu”, sub-sub-menu shows expanded by defult and can’t collapse it, do you know why?

    Here you can check it: https://imgur.com/a/KCfmfhB

    The way to change the dropdown menu line (or border?) color at CSS is: border-top: [color] ?, the only way I know to change is to select the colour at Divi > Theme Customizer > Header & Navigation > Primary Menu Bar > Dropdown Menu Line Color.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Emaux!

      We are glad that our content helps you with your website. Coming onto the issue, for our better clarity could you please share the URL of the website for us to investigate further?

      Reply
  50. Tom Tom

    Hi Nelson,

    I really enjoyed this tutorial, the main code works wonderfully (replacing a hefty plugin that was conflicting with others!)

    My only problem is that the JS for “Use Parent Menu Item As Toggle For Submenu” doesn’t seem to be working for me.

    Could you take a quick look for me?

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Tom!

      Apologies for the trouble. There was a little syntax error in the code. We have corrected it. The script should work fine now. 👍

      Reply
      • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

        Hi Brian!

        Thank you for bringing our attention to the issue. I have updated the code above. Please use the one and see if it helps.

      • Brian

        Hi. I tried the parent toggle code today and it doesn’t seem to work. Please take a look and thank you! https://rainbowplays.com/

  51. Seb

    Hi,

    thanks for the tutoiral. Has so far worked great.
    One more question. It would be good if the dropdown menu also opens when you click on the menu title. I thought this works with the code under “Option: Use Parent Menu Item As Toggle For Submenu”. I added the code in addition to the other one but unfortunately it has no effect. When I click on the menu item the complete menu closes again. So the dropdown opens only if I click exactly on the arrow.

    Do you have any tips on how this could work?

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Seb!

      Thank you for bringing it to our attention. For now, to make the whole parent menu item to open sub menu toggle:

      ul.et_mobile_menu li.menu-item-has-children .mobile-toggle, .et-db #et-boc .et-l ul.et_mobile_menu li.menu-item-has-children .mobile-toggle{
      width: 100% !important;
      text-align: right !important;
      }

      Let me know how it goes!

      Reply