Reputation: 865
I have a navigation where the active boxes should be black and the non-active boxes are white however they all stay white. I'm trying to get it so that say you press the 4th box, all the boxes leading to the 4th would be coloured black.
.nav__link--active .nav__link-bullet{
-webkit-animation: bounce .40s linear;
animation: bounce .40s linear;
background-color: black;
}
It seems to be overridden by
.nav__link-bullet{
display: block;
height: 20px;
width: 20px;
background-color: white;
}
but I can't seem to get it to work right.
Upvotes: 1
Views: 75
Reputation: 4808
In your javascript file, you have to define the click
event of the nav elements to remove all active
classes and make the div
parent active
$('.nav__link a').click(function(){
$('.nav__link').removeClass('nav__link--active')
$(this).parent().addClass('nav__link--active');
})
Here is the example on jsBin
Upvotes: 1