jQuery - 根据url定位导航位置

思路:
1.获取当前页面的pathname
2.找到带有值为 当前pathname的href 所在的a标签。
3.将css属性赋值给找到的a标签

  var getUrl = window.location.pathname;
  var navUrl = $("a[href$='" + getUrl + "']");
  navUrl.parent(".sideBarKids").show();
  navUrl.children("li").css("background-color", "#0f6f9f");
posted @ 2018-02-11 10:45  DebraJohn  阅读(106)  评论(0编辑  收藏  举报