Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Hide mobile menu when li is clicked - bootstrap

Hi guys, don't know if this is the correct section for this question but..

I've made a site.. almost everything is done! you can check him out over here: www.dev.bhuge.nl

But there is one problem. When you click on a menu item the hamburger dropdown doesn't goes up. I have tried many things but can't get it working properly..

Can you guys help me?

I think you posted the wrong link.

No, it's not my personal website

Sorry. I misread your question. I understand what you mean now.

Can you help me? :D

I'll take a look

1 Answer

It's difficult to understand what's going on without seeing your exact code, but I suppose you could add a click listener to the menu items to either directly hide the menu, or trigger a click event on the nav bar which should also hide the menu.

example:

$('.navbar-nav').find('a').on('click', function(e){
  $('.navbar-toggle').trigger('click');
});

Thx, worked perfectly