i have a menu that have the route like this (about / services / basic services) . i want when i click on basic services after the page refresh the active li goes on basic services li tag . and other tags removed from active class . how can i do it?|
<nav id="menu">
<ul>
<li class="active"><a href="#/">Home</a></li>
<li><span>About</span>
<ul>
<li><span>Services</span>
<ul>
<li><a href="./index.html">basic sevices</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#/contact">Contact</a></li>
</ul>
</nav>
and js:
var url = location.href;
console.log(url);
if ($(".mm-panels li").children("a").attr("href") == url) {
$(this).addClass("active");
}
i tried the js above vut after refreshing page it is not working.