Jump to content

Bootstrap, how can I make a navbar class="active" when navbar is a single file

Guest
Go to solution Solved by BlueDragon,

Ah ha!!! I got it. Bootstrap uses the <li> element for its active styling... just update this function in your fetch.js

function setPage(nav) {	hrefString = document.location.href ? document.location.href : document.location;	console.log(extractPageName(hrefString));	if (document.getElementById(extractPageName(hrefString)) != null){		document.getElementById(extractPageName(hrefString)).className = "active";		if (document.getElementById(extractPageName(hrefString)).parentNode.tagName == "LI")				document.getElementById(extractPageName(hrefString)).parentNode.className = "active";	}}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×