Php 管理员侧栏活动菜单不显示';不能动态变化

Php 管理员侧栏活动菜单不显示';不能动态变化,php,jquery,anchor,sidebar,adminlte,Php,Jquery,Anchor,Sidebar,Adminlte,错误|帮助 当我试图更改nav链接上的类时,jquery无法正确启动。也许这已经被其他js阻止了 我正在创建我的index.php文件,其中包括once header.php、sidebard.php和footer.php 从侧边栏菜单中选择条件后,会调用某些页面。我尝试在单击另一项时更改活动导航链接,并将“活动”添加到类中。但它就是不点火 下面是我的侧边栏.php的内容 ` 总部 联系人:(上午9:30–下午4:00)+1234567890电

错误|帮助 当我试图更改nav链接上的类时,jquery无法正确启动。也许这已经被其他js阻止了

我正在创建我的index.php文件,其中包括once header.php、sidebard.php和footer.php 从侧边栏菜单中选择条件后,会调用某些页面。我尝试在单击另一项时更改活动导航链接,并将“活动”添加到类中。但它就是不点火

下面是我的侧边栏.php的内容

`


    • 总部
      联系人:(上午9:30–下午4:00)
      +1234567890
      电子邮件:
      someone@somewhere.com

`

下面是我的footer.php,其中包括启动操作的jquery

<!-- script to change the selected active nav-link -->

<script>$(document).ready(function () { 
$('.nav-link').click(function(e) {
$('.nav-link').removeClass('active');        
$(this).addClass("active");

});
});
</script>

$(文档).ready(函数(){
$('.nav link')。单击(函数(e){
$('.nav link').removeClass('active');
$(此).addClass(“活动”);
});
});
环境

  • 管理员版本:[例如v3.0.4]
  • 操作系统:[例如Microsoft Windows 10]
  • 浏览器(版本):[例如Chrome(最新版本)]
我错过什么了吗?任何人都可以帮我。

/**添加活动类并在选中时保持打开状态*/
var url=window.location;
const allLinks=document.queryselectoral('.nav item a');
const currentLink=[…所有链接].filter(e=>{
返回e.href==url;
});
如果(currentLink.length>0){//由于某些链接不是来自菜单,请使用此筛选器
currentLink[0]。类列表。添加(“活动”);
//currentLink[0]。最近的(“.nav treeview”).style.display=“block”;
//currentLink[0]。最近的(“.has treeview”)。类列表。添加(“活动”);
}

管理LTE 3的

如果要输入url,例如:url/edit/3
这个代码对我有用:


欢迎来到StackOverflow!请提供一个解释,以使给定的代码更易于理解
<!-- script to change the selected active nav-link -->

<script>$(document).ready(function () { 
$('.nav-link').click(function(e) {
$('.nav-link').removeClass('active');        
$(this).addClass("active");

});
});
</script>
$(function () {
    var url = window.location;
    // for single sidebar menu
    $('ul.nav-sidebar a').filter(function () {
        return this.href == url;
    }).addClass('active');

    // for sidebar menu and treeview
    $('ul.nav-treeview a').filter(function () {
        return this.href == url;
    }).parentsUntil(".nav-sidebar > .nav-treeview")
        .css({'display': 'block'})
        .addClass('menu-open').prev('a')
        .addClass('active');
});
/*** add active class and stay opened when selected ***/
var url = window.location;

// for sidebar menu entirely but not cover treeview
$('ul.nav-sidebar a').filter(function() {
    if (this.href) {
        return this.href == url || url.href.indexOf(this.href) == 0;
    }
}).addClass('active');

// for the treeview
$('ul.nav-treeview a').filter(function() {
    if (this.href) {
        return this.href == url || url.href.indexOf(this.href) == 0;
    }
}).parentsUntil(".nav-sidebar > .nav-treeview").addClass('menu-open').prev('a').addClass('active');