Bootstrap navbar Active State is not working.
I have bootstrap v3.
I use the class="active" on mynavbar on its submenu when I collapse none work.
Here is my code with js/css/bootstrap files I have included:
<li class="active">
<a href="javascript:;" data-toggle="collapse" data-target="#demoadmin">
<i class="fa fa-fw fa-wrench"></i>Administrator Menu <i class="fa fa-fw fa-caret-down"></i>
</a>
<ul id="demoadmin" class="collapse in">
<li class="active">
<a href="linkmanagement.php#">Links Editor</a>
</li>
<li>
<a href="editortable.php">News Editor</a>
</li>
<li>
<a href="main_category.php">Main Category Editor</a>
</li>
<li>
<a href="sub_category.php">Sub Category Editor</a>
</li>
<li>
<a href="editorprofile.php">Profile Team Editor</a>
</li>
</ul>
</li>
You didn't show us enough HTML to see exactly what you are doing wrong, but it looks like you're trying to get the active
class to work on a bootstrap dropdown-menu
.
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-wrench"></i>Administrator Menu <i class="fa fa-fw fa-caret-down"></i>
</a>
<ul class="dropdown-menu">
<li class="active">
<a href="linkmanagement.php#">Links Editor</a>
</li>
<li>
<a href="editortable.php">News Editor</a>
</li>
<li>
<a href="main_category.php">Main Category Editor</a>
</li>
<li>
<a href="sub_category.php">Sub Category Editor</a>
</li>
<li>
<a href="editorprofile.php">Profile Team Editor</a>
</li>
</ul>
</li>
Try this
$(document).ready(function(){
$(".active").removeClass("active");
$(".dropdown-menu li").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.