In a website, I am trying to get this specific navbar active class to work. When I click on the current page, I would like the link to turn blue. Since I am a beginner, any help would be really appreciated. Thanks in advance.
Here is the navbar :
<div class="nav-scroller py-1 mb-2">
<nav class="nav d-flex justify-content-between">
<a class="active p-2 text-muted" href="#"><b> Business</b> </a>
<a class="p-2 text-muted" href="#"><b> Design </b></a>
<a class="p-2 text-muted" href="#"><b>Travel </b></a>
<a class="p-2 text-muted" href="#"><b> Opinion </b></a>
</nav>
</div>
Here is the javascript code:
$('.nav .p-2 .text-muted').click(function(){
$('.nav .p-2 .text-muted').removeClass('active');
$(this).addClass('active');
})
I also used CSS to turn the current navbar page link to blue:
.nav > .p-2.activate {
color:blue;
}