I want to make a side menu, and change the class when clicking.
When i click on the "li" with no class="active", i want the jquery to add a class on the empty
<div id="sidebar">
<ul class="nav nav-pills nav-stacked">
<li>
@Html.ActionLink("Home", "Index", "Home", new { @class = "ach" })
</li>
<li>
@Html.ActionLink("About Us", "About", "Home", new { @class = "ach" })
</li>
<li>
@Html.ActionLink("Contact Us", "Contact", "Home", new { @class = "ach" })
</li>
</ul>
javascript which i used is:
$('.ach').on('click', function () {
debugger;
$('li').removeClass('active');
$(this).parent().addClass('active');
});