'Link active effect not working while loading in new page
After click in page link, this jQuery doesn't remove active class from unclicked link and also not implementing this class in clicked item. It seems not working for page load. Is there any solution for it.
$(document).ready(function () {
$('a').click(function() {
$('a').removeClass('active');
$(this).addClass('active');
})
});
.active {
color: red
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<div>
<a class="active" href="page1.html">Page 1</a>
<a href="page2.html">Page 2</a>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
