Close Navbar When Nav Link is Clicked

Download FREE Marketing Guides

By default the navbar dropdown stays open when clicked. This can be an issue if you are using name anchor’s or linking to an id like href=”#section”

// Close Bootstrap 3 navbar when a nav item is clicked
$('.navbar-collapse ul li a:not(.dropdown-toggle)').bind('click touchstart', function () {
  $('.navbar-toggle:visible').click();
});

Written by: Jake Lett
I share digital marketing tips and HubSpot tutorials to help marketers and business owners grow their business.

Related posts

Tags:

Want to Get Email Updates of New Articles?

Join My Email Newsletter