I am trying to get the current sidebar item highlighted, i used this code:
<ul class="app-menu">
<li><a class="app-menu__item" href="@Url.Action("Index","Home")">Accueil</a></li>
<li><a class="app-menu__item" href="#">Categories</a></li>
<li><a class="app-menu__item" href="@Url.Action("Index","Stock")">Stock</a></li>
<li><a class="app-menu__item" href="@Url.Action("Index","Article")">Article</a></li>
</ul>
Javascript
<script>
$(".app-menu li a").click(function () {
$(".app-menu li a.active").removeClass("active");
$(this).addClass("active");
});
</script>
But this code isn’t working. what’s wrong with this?
2
Answers
Remove "…" and use ‘…‘ :
Please check below code, I think there is a problem with your href link