R
R
RushV2021-07-01 15:40:55
JavaScript
RushV, 2021-07-01 15:40:55

Implement hover function on menu items?

I welcome everyone!
I myself wanted to implement all this, but I can’t see how to do it normally.
Please help!
There is a navigation structure made by boostrap 5:
60ddb3ce1bab1590187635.jpeg
When clicking on a link with the class "submenu-2", "submenu-6", etc., the "show" class was added to the "dropdown-menu-custom"

let subMenu = $('ul.navbar-main a[id^=submenu]').click(function(){
        $('.dropdown-menu').closest('.dropdown-menu-custom').addClass('show');
        
    });

Now, when clicked, it is added to all menus with the "dropdown-menu-custom" class.
Thank you in advance for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
v3shin, 2021-07-01
@RushV

$('ul.navbar-main a[id^="submenu"]').click(function(){
    $(this).closest('.dropdown-menu').find('> .dropdown-menu-custom').addClass('show');
});

And figure out what the line does:
$('.dropdown-menu').closest('.dropdown-menu-custom').addClass('show');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question