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");

  }

});

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM