<ul class="nav sidebar-menu">
<li >
<a href="/admin/index">
<i class="menu-icon glyphicon glyphicon-home"></i>
<span class="menu-text"> 后台首页 </span>
</a>
</li>
<li>
<a href="#" class="menu-dropdown">
<i class="menu-icon fa fa-inbox"></i>
<span class="menu-text"> 产品 </span>
<i class="menu-expand"></i>
</a>
<ul class="submenu">
<li >
<a href="/admin/product/lst">
<span class="menu-text">产品列表</span>
</a>
</li>
<li >
<a href="/admin/size/lst">
<span class="menu-text">码数管理</span>
</a>
</li>
<li >
<a href="/admin/cate/lst">
<span class="menu-text">产品分类</span>
</a>
</li>
</ul>
</li>
<li> //这个li下面的li里面存在active这个class,给这个li增加class="open"
<a href="#" class="menu-dropdown">
<i class="menu-icon fa fa-user"></i>
<span class="menu-text"> 管理员 </span>
<i class="menu-expand"></i>
</a>
<ul class="submenu">
<li >
<a href="/admin/user/lst">
<span class="menu-text">管理员列表</span>
</a>
</li>
<li class="active"> //这个li里面包含了active这个class,我想给上级li增加一个class="open",应该怎么写才对?
<a href="/admin/authrule/lst">
<span class="menu-text">权限列表</span>
</a>
</li>
<li >
<a href="/admin/authgroup/lst">
<span class="menu-text">用户组</span>
</a>
</li>
</ul>
</li>
<li>
<a href="#" class="menu-dropdown">
<i class="menu-icon fa fa-gear"></i>
<span class="menu-text"> 系统设置 </span>
<i class="menu-expand"></i>
</a>
<ul class="submenu">
<li >
<a href="/admin/conf/lst">
<span class="menu-text">配置列表</span>
</a>
</li>
<li >
<a href="/admin/conf/conf">
<span class="menu-text">配置项</span>
</a>
</li>
</ul>
</li>
</ul>
I don’t know how to express it, so I wrote the question in the code above. Please forgive me.
If the level is not deep, you can use
parents
to get it, such as:What operation do you want to do? .
Give you some code
If you just want to check, you can
If you just want to find all parents of a selected li
If it is li in the parent
If there is more than one active, you can first use filter or add a condition to find the one you need.