这里有添加,查看和编辑页面。当我点击添加和查看页面时,页面变为活动状态,父项也变为活动状态。但是当我点击视图页面中显示的编辑页面时,父项没有变得活跃。 这是我的观点页面
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-bed"></i> Room Management <b class="fa fa-plus dropdown-plus"></b> </a>
<ul class="dropdown-menu">
<li class="<?php if($active_mn=='add_class') echo "active";?>"> <a href="<?php echo base_url()?>admin/add_class"> <i class="fa fa-caret-right"></i>Add Class</a> </li>
<li class="<?php if($active_mn=='view_class') echo "active";?>"> <a href="<?php echo base_url()?>admin/view_class"> <i class="fa fa-caret-right"></i>View Class</a> </li>
<li class="<?php if($active_mn=='add_rooms') echo "active";?>"> <a href="<?php echo base_url()?>admin/add_rooms"> <i class="fa fa-caret-right"></i>Add Rooms</a> </li>
<li class="<?php if($active_mn=='view_rooms') echo "active";?>"> <a href="<?php echo base_url()?>admin/view_rooms"> <i class="fa fa-caret-right"></i>View Rooms</a> </li>
</ul>
</li>
从视图页面开始编辑页面,这里是代码
<td><a class="btn btn-success active" href="<?php echo base_url() ?>admin/edit_hostel/<?php echo $row->id ?>"> Edit </a> </td>
这是我使用菜单变为活动的脚本
<script>
$(document).ready(function () {
var url = window.location;
$('ul.dropdown-menu a[href="' + this.location.pathname + '"]').parent().addClass('open active');
$('ul.dropdown-menu a').filter(function() {
return this.href == url;
}).parent().parent().parent().addClass('open active');
});
</script>
答案 0 :(得分:0)
var url = window.location;
$('ul.dropdown-menu a[href*="' + this.location.pathname + '"]').parent().addClass('open active').closest('li').addClass('open active');
});
答案 1 :(得分:0)
<li class="dropdown <?php if($active_mn=='view_class'|| $active_mn=='view_rooms') echo "open active";?>"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-bed"></i> Room Management <b class="fa fa-plus dropdown-plus"></b> </a>
<ul class="dropdown-menu">
<li class="<?php if($active_mn=='add_class') echo "active";?>"> <a href="<?php echo base_url()?>admin/add_class"> <i class="fa fa-caret-right"></i>Add Class</a> </li>
<li class="<?php if($active_mn=='view_class') echo "active";?>"> <a href="<?php echo base_url()?>admin/view_class"> <i class="fa fa-caret-right"></i>View Class</a> </li>
<li class="<?php if($active_mn=='add_rooms') echo "active";?>"> <a href="<?php echo base_url()?>admin/add_rooms"> <i class="fa fa-caret-right"></i>Add Rooms</a> </li>
<li class="<?php if($active_mn=='view_rooms') echo "active";?>"> <a href="<?php echo base_url()?>admin/view_rooms"> <i class="fa fa-caret-right"></i>View Rooms</a> </li>
</ul>
</li>