How to change color of oppened link in bootstrap menu like on picture. It work on mouse over and after click change to default color of menu. i need like on picture.
HTML
<div class="navbar-left">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Патници", "Index", "patnici")</li>
<li >@Html.ActionLink("Помош", "Contact", "Home")</li>
</ul>
</div>
CSS
.navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
line-height: 20px;
}
need to set active class. See the solution here
Below code might help , change the color accordingly of your choice below
.navbar-nav li a {
background:#C60;
color:#FFFFFF;
text-decoration:none;
display: block;
}
.navbar-nav li a:visited {
background:yellow;
color:#F00;
text-decoration:none;
}
This might help. Create a css class "active" and set a background-color.
$(function() {
$("li").click(function() {
// remove existing class
$("li").removeClass("active");
// add class to the one we clicked
$(this).addClass("active");
});
});
$(".nav a").on("click", function(){
$(".nav").find(".active").removeClass("active");
$(this).parent().addClass("active");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.