I have the menu down, which is contained in the page empresas.php
and to "Edit" a company becomes editar-empresa.php?id=x
:
Thefunctionthataddstheclassactive
tothecurrentpageisasfollows:
(function(){varnav=document.getElementById('menu'),anchor=nav.getElementsByTagName('a'),current=window.location.href.split("?")[0];
for (var i = 0; i < anchor.length; i++) {
if(anchor[i].href.split("?")[0] == current) {
anchor[i].children[0].className = "active";
}
}
})();
That is, the "Business" section will remain highlighted only if it is on the empresas.php
page, but I need it to remain highlighted when going to the editar-empresa.php?id=x
subsection. What should I do to achieve this?
HTML:
<div id="menu">
<nav>
<ul>
<a href="emissor-nfe.php"><li>Emissor NF-e</li></a>
<a href="empresas.php"><li>Empresas</li></a>
<a href="clientes.php"><li>Clientes</li></a>
<a href="produtos.php"><li>Produtos</li></a>
<a href="transportadoras.php"><li>Transportadoras</li></a>
<a href="logout.php"><li>Sair</li></a>
</ul>
</nav>
</div>