I need to make the link which is clicked on to be active. I have the following code down below and i tried different script codes to make the link active but it doesnt seem to work. What seems to be the problem?
$("a").click(function () {
if ($(this).hasClass("active")) {
$(this).removeClass("active");
} else {
$(this).addClass("active");
}
});
nav ul li a:hover,
nav ul li a.active {
color: #23dbdb;
}
<nav>
<ul>
<li><a class="active" href="Login.html" target="dest">Home</a></li>
<li><a href="buttonsstudent.html" target="dest">Result</a></li>
<li><a href="card4.html" target="dest">Subjects</a></li>
<li><a href="aboutpage.html" target="dest">About</a></li>
</ul>
</nav>