活动按钮不起作用(ADMIN LTE)

时间:2017-02-16 08:28:16

标签: javascript jquery html twitter-bootstrap

我在管理员方面使用管理员LTE模板。当我转到其他页面时,该页面的按钮将不会激活。我观察到激活那个按钮的方式是必须的,而且必须是里面的li 我怎么能用jquery

来做呢
<li class="treeview">
    <a href="#">
       <i class="fa fa-laptop"></i>
       <span> Manage Catalog</span>
       <span class="pull-right-container">
          <i class="fa fa-angle-left pull-right"></i>
       </span>
    </a>
    <ul class="treeview-menu">
       <li><a href="<?= base_url() .'administrator/products' ?>"><i class="fa fa-circle-o"></i> Products</a></li>
       <li><a href="pages/UI/icons.html"><i class="fa fa-circle-o"></i> Discount/Promos</a></li>
    </ul>
</li>

2 个答案:

答案 0 :(得分:0)

首先给&#34; li&#34;标签,例如,productMenu和DiscountMenu

<ul class="treeview-menu">
     <li id="productMenu"><a href="<?= base_url() .'administrator/products' ?>"><i class="fa fa-circle-o"></i> Products</a></li>
     <li id="DiscountMenu"><a href="pages/UI/icons.html"><i class="fa fa-circle-o"></i> Discount/Promos</a></li>
</ul>

要在icons.html中添加的脚本代码:

<script>
    var path = window.location.pathname;
    if(path.indexOf("icons.html")!==-1){
        $("#DiscountMenu").addClass("active");
        $("#productMenu").removeClass("active");
    }
</script>

答案 1 :(得分:0)

请尝试此

<li class="treeview active">
<a href="#">
   <i class="fa fa-laptop"></i>
   <span> Manage Catalog</span>
   <span class="pull-right-container">
      <i class="fa fa-angle-left pull-right"></i>
   </span>
</a>
<ul class="treeview-menu">
  <li class="active"><a href="<?= base_url() .'administrator/products' ?>"><i class="fa fa-circle-o"></i> Products</a>
  </li>
</ul>