When you press one of the jquery hamburger menus,

Asked 2 years ago, Updated 2 years ago, 42 views

I want to go back to page # while hiding the menu by pressing one of the menus in the hamburger menu.

You can hide it by pressing the icon on the hamburger menu, but it doesn't hide it when you press the menu.The hamburger menu is fixed.
I look forward to your kind cooperation.

source code

<divid="navigation">
        <div class="navigation_inner">
          <ul class="navigation_menu">
            <lic class="navigation_item"><a href="#skills">SKILLS</a><li>
            <lic class="navigation_item"><a href="#works">WORKS</a><li>
            <lic class="navigation_item"><a href="#contact">CONTACT</a></li>

          </ul>
        </div>
</div>


jQuery('.hamburger').on('click', function(){
    jQuery('#navigation').fadeToggle(600);
    jQuery("#skills").click(function(){
        jQuery('#navigation').fadeToggle(false);
    });
});

Actual results

Enter a description of the image here

jquery css

2022-09-30 19:21

1 Answers

When you click the menu icon, the process includes event registration when you click a list item, so I think it would be better to separate them.

Also, if you click on a list item, you should register for the navigation_item class that the item has in common.

// When you press the menu icon
jQuery('.hamburger').on('click', function(){
    jQuery('#navigation').fadeToggle(600);
});

// When you press an item,
jQuery('.navigation_item') .on('click', function(){
    jQuery('#navigation').fadeOut();
});


2022-09-30 19:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.