1. PROMO Subscribe our All Access Pass @ 75% OFF & access all our 16+ premium Divi extensions: Divi Block Pro, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Solved Clickable dropdown submenu closed when the menu itself is clicked

Discussion in 'Free Divi Community Forum' started by John Waluthon, Apr 27, 2021.

  1. John Waluthon

    John Waluthon New Member

    Hello everyone. I haven't been able to solve this one problem regarding the submenu on DIVI. As we all know, the default DIVI submenu can be shown when user hovers the cursor to the parent menu-item. On my website, I want the submenus to be clickable.

    So far, I wrote both customize jquery and CSS codes to achieve that clickable functionality. It works but not as I expected. I want the current opened dropdown submenu to be closed not only when the user click the window or other submenu, but also when the user click that current opened menu itself. Until now, that functionality hasn't worked despite multiple attempts I made and it's quite frustrating. Here are the jquery codes:
    Code:
    Log In or Sign Up to view this code.
    Below are short CSS codes that I wrote to show the clicked menu and hide all the opened (hovered) menus:
    Code:
    Log In or Sign Up to view this code.
    To give a little bit of context to what's going on when these codes are applied, is that the dropdown submenu can be opened by clicking (no longer hover), and at the same time close the current opened submenu. User can also close the submenu by clicking the window. I would really appreciate all the feedback this community could give. Thank you so much!
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade gradient text design for your Divi site without using any plugins:View Demo
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    Find this:

    $('.sub-menu').removeClass('visible');

    And replace with:

    $('.sub-menu').not($(this).next('.sub-menu')).removeClass('visible');
     
  3. John Waluthon

    John Waluthon New Member

    You are my saviour! It works as expected. Thank you so much!
     
    1. PRO MEMBER PERKS Divi Cart Count Plugin - Easily add cart count to your Divi cart icon. 6 different styles to choose from:Learn More