Topic: Hamburger Menu close automatic by clicking Menu Item, not only by clicking Toggler "X"
kaiwiessner asked 5 years ago
How can I close the Menu, by clicking for example the HOME Menu item? I need this function on an onepager.
The normal Hamburger-Menu Snippet only closes by clicking the toggler again.
The toggler itself also needs to get back in normal burger menu style when closed..
$(document).ready(function () {
$('.first-button').on('click', function () {
$('.animated-icon1').toggleClass('open');
});
});
kaiwiessner answered 5 years ago
Hi,
$('.animated-icon1').trigger('click')
won't work for me. Thank you anyway!
Now I figured out how it works for me:
$(document).ready(function() {
$('.first-button').on('click', function () {
// console.log('debug');
$('.animated-icon1').toggleClass('open');
});
$(".nav-link").on("click", function() {
var elem = $("#navbarSupportedContent20");
if(elem.hasClass('show')) {
elem.toggleClass('show');
$('.animated-icon1').toggleClass('open');
}
});
});
Mateusz Łubianka staff answered 5 years ago
Hi @kaiwiessner,
Try to use this code:
$('.navbar-nav').on('click', function() {
$('.animated-icon1').trigger('click')
})
Best,
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.11.0
- Device: Macbook Pro
- Browser: Chrome
- OS: Mojave
- Provided sample code: No
- Provided link: No