0

I have a "one page scroll" website with Twitter bootstrap framework.

On desktop view, my top navbar is always visible and the different links of the top navbar anchor the user to the different sections of the page.

On mobile view, the top navbar is collapsed by default. The user has to tap on the burger menu of the top navbar to expand it, and then tap on a link to automatically scroll to the section. The problem is that on mobile view, after taping a link, the top navbar doesn't collapse and stay open, user has to close it manually.

What CSS or JS should I use to automatically close the navbar after the user tap on a link for mobile view only?

1 Answers1

2

Try this (I'm assuming bootstrap 3

$('.nav a').on('click', function(){
  $(".navbar-toggle").click() //bootstrap 3.x
});
Macsupport
  • 5,406
  • 4
  • 29
  • 45