I am working on the correct menu and I want to save this state with the link tag hrefwith the location of the addresses.
function setNavigation() {
var path = window.location.pathname;
path = path.replace(/\/$/, "");
path = decodeURIComponent(path);
$(".sidebar-menu li ul a").each(function () {
var href = $(this).attr('href');
if (path.substring(0, href.length) === href) {
$(this).addClass('active-item');
}
});
The problem is that the code does not recognize the same addresses in oneul
for example, both bottom elements give a class active-item.
href="site/city/company/"
href="site/city/company/sample"
also here is my html
<li><a href="/Panel/Place" class="active-item"></a></li>
<li><a href="/Panel/Place/item" class="active-item"></a></li>
<li><a href="/Panel/Place/City"></a></li>
<li><a href="/Panel/Definitions/Attribute">/a></li>
<li><a href="/Panel/TouristDestination"></a></li>
source
share