I want to set active link background to some color even while moved to clicked URL. I have tried this but it is changing background but while it navigate to clicked URL all things set to default.
I am trying to add active class to clicked menu using JQuery. Code is like this.
HTML
<ul>
<li class="menu-item"><a href="#">HOME</a></li>
<li class="menu-item"><a href="#">COMPANY PROFILE</a></li>
<li class="menu-item"><a href="#">PRODUCTS</a></li>
<li class="menu-item"><a href="#">CONTACT US</a></li>
<li class="menu-item"><a href="#">ENQUIRY</a></li>
</ul>
CSS
.menu-item a{
text-decoration: none;
color: #FFF;
font-weight: bold;
padding: 7px 15px;
line-height: 43px;
font-family: "Lucida Sans Unicode","Lucida Grande",sans-serif;
font-size: 13px;
letter-spacing: 1px;
text-shadow: 2px 2px #555;
}
.menu-item a:hover{
background: #871304;
opacity: 0.8;
border-radius: 20px;
}
.menu-item .active{
background-color:#FFF;
color:black;
border-radius: 20px;
}
JQUERY
$(".menu-item a").click(function(){
$(".menu-item a").addClass('active').siblings().removeClass('active');
});
Please let me know that where I am making mistake?