Dragon
主机之家测评主机之家测评  2020-07-06 19:43 主机之家测评 隐藏边栏 |   抢沙发  83 
文章评分 6 次,平均分 1.0

AdminLTE 主题左侧 Menu菜单切换样式自动变化代码,将下面代码添加到对应版本的 AdminLTE 主题的页面 footer 处即可。

AdminLTE 3:

  <script>  $(document).ready(function() {    /** 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() {        return this.href == url;    }).addClass('active');    // for treeview    $('ul.nav-treeview a').filter(function() {        return this.href == url;    }).parentsUntil(".nav-sidebar > .nav-treeview").addClass('menu-open').prev('a').addClass('active');  })  </script>

AdminLTE 2.4.*:

  <script>  $(document).ready(function() {  /** add active class and stay opened when selected */  var url = window.location;   // for sidebar menu entirely but not cover treeview  $('ul.sidebar-menu a').filter(function() {      return this.href == url;  }).parent().siblings().removeClass('active').end().addClass('active');   // for treeview  $('ul.treeview-menu a').filter(function() {      return this.href == url;  }).parentsUntil(".sidebar-menu > .treeview-menu").siblings().removeClass('active').end().addClass('active');  })  </script>

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

发表评论

扫一扫二维码分享