1. 程式人生 > >給當前頁或者跳轉後頁面的導航欄添加選中樣式

給當前頁或者跳轉後頁面的導航欄添加選中樣式

cat oca [0 ddc == list ring this ref


$("ul.nav-list li a").each(function () {
//$("ul.nav-list li").removeClass("active");
if ($($(this))[0].href == String(window.location))
if ($(this).parent().find("li").length == 0) {
$(this).parent().addClass("active");
}
else {
$(this).parent().addClass("active open");

}
});

給當前頁或者跳轉後頁面的導航欄添加選中樣式