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