reminator
reminator

Reputation: 3

How to find the current nav Li "active" in bootstrap nav

I need to get the current nav clicked in my bootstrap menu, I know it has an "active" class added to the LI tag, but after looking a lot online and on the bootstrap site, Bootstrap does not seem to offer any JavaScript value containing the current nav...

anybody has an idea how to get this through a JavaScript function?

Upvotes: 0

Views: 1311

Answers (2)

reminator
reminator

Reputation: 3

FOUND IT! Leaving this here in case anybody else needs the info :

var currentView = $(".nav li.active > a").text();

(Note that you need to have scroll spy enabled)

Upvotes: 0

Rudi
Rudi

Reputation: 2995

Using jQuery, you can get it like:

var $activeItem = $('.nav .active');

Upvotes: 0

Related Questions