ace admin 左侧菜单定位

后台模版来自:Ace Admin

http://ace.jeka.by/form-elements.html

左侧菜单,通过js根据url来判断显示哪块

 

window.location.pathname: 代表URL 的路径部分(就是文件地址)
本例返回值:/Company/AddOrEditCompany

 

window.location.search: 代表查询(参数)部分
除了给动态语言赋值以外,我们同样可以给静态页面,并使用javascript来获得相信应的参数值
本例返回值:?id=6

 

Js代码如下:

var pathname = window.location.pathname + window.location.search;

$(".nav li a").each(function() {

  var href = $(this).attr("href");

  if(pathname == href){

    $(this).parents("ul").parent("li").addClass("active open");

    $(this).parent("li").addClass("active");

  }

});

 

posted @ 2017-05-27 11:29  墨墨爱糖果  阅读(1608)  评论(0编辑  收藏  举报