I am trying to add class for selected menu using jquery stuff. I tried the following method,its not working.
And my code is
<div class="paragraph">
<ul class="tablinkss">
<li class="active">@Html.ActionLink("Login", "LogOn")</li>
<li>@Html.ActionLink("Register", "Register")</li>
</ul>
</div>
And my jquery
$(function () {
$('ul.tablinkss li').click(function () {
$('ul.tablinkss li').removeClass("active");
$(this).addClass("active");
});
});
Thanks,
Html.ActionLinkreturns a hyperlink that will have the browser load a new page. JavaScript will not work in this case unless you are preventing the link from loading the next page. Well, it will work for a split second then the browser will show the new page.You need to fix this in your Razor template and not in JavaScript.