Site logo

Archived topic

Slidout menu collapse on dropdown click

5 replies · Started by Christine on April 4, 2020

Viewing posts 1–6 of 6

Hi,

In my website I would lke to have a functionality on mobile slide out menu like if I click the one drop down section it opens, when I click on second/any other drop down the previously opened dropdown should get collapsed.
Please let me know how we can do it. This is for your reference. https://prnt.sc/rst7hj

Regards

Hi Leo, Thank you for your response. I have added this code in my website but i cannot see the difference. I have added as a hook in wp_head.

<script>
    jQuery( document ).ready( function( $ ) {
        $( '.main-navigation ul ul li.menu-item-has-children > a' ).on( 'click', function() {
            $( this ).closest( 'li' ).siblings().removeClass( 'sfHover' ).find( '.sub-menu' ).removeClass( 'toggled-on' );
        } );
    } );
</script>

We are clicking on the arrow and checking this. If I click on Parent sub menu item then we will be redirected to a different page so we don't need it there.

Please visit blissfulweddingfeet.com.au/ and check by yourself once.

Thanks

Can you try this instead?:

<script>
    jQuery( document ).ready( function( $ ) {
        $( '.main-navigation ul ul li.menu-item-has-children > a > .dropdown-menu-toggle' ).on( 'click', function() {
            $( this ).closest( 'li' ).siblings().removeClass( 'sfHover' ).find( '.sub-menu' ).removeClass( 'toggled-on' );
        } );
    } );
</script>

Hey This worked... Thanks....

No problem!

This archived topic is closed to new replies.