更改外部html标题活动菜单 [英] Change external html header active menu
本文介绍了更改外部html标题活动菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个外部Bootstrap导航栏标题,我在每个页面中都包含
I have an external Bootstrap navbar header which I include in every page as
<?php include("header.html");?>
外部标题html文件如下:
The external header html file is given below:
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active"><a href="homepage.php" >Home</a></li>
<li ><a href="aboutus.php">About Us</a></li>
<li><a href="#">Events</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Members<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">4th Year</a></li>
<li><a href="#">3rd Year</a></li>
<li><a href="#">2nd Year</a></li>
<li><a href="#">1st Year</a></li>
</ul>
</li>
<li><a href="#">Gallery</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li id="register"><a href="register.php"><span class="glyphicon glyphicon-user"></span>Register</a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span>Login</a></li>
</ul>
</div>
</div>
</nav>
我面临的问题是更改活动菜单。我试过各种各样的方法,但还没有成功。
如果您有任何想法,请提供帮助。
The problem I am facing is changing the active menu. I tried various ways but no success yet. Please help if you have any idea.
推荐答案
您可以使用php通过POST / GET发送变量相应地设置类,或者您可以尝试使用jquery查找每个页面中存在的特定元素并相应地添加一个类,例如
You can either send a variable through POST/GET using php and set the class accordingly, or you can try using jquery to find specific elements that exist in each page and add a class accordingly, for example
if ($('#specific-page-element-1').length) {
$('menuelement-1').addClass('active');
}
这篇关于更改外部html标题活动菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文