現在開いているページをJqueryでactive(アクティブ)にCSSで表示する
以下を設置すればOK!
< script > |
$(function(){ |
$('#gmenu li a').each(function(){ |
var $href = $(this).attr('href'); |
if(location.href.match($href)) { |
$(this).addClass('active'); |
} else { |
$(this).removeClass('active'); |
} |
}); |
}); |
</ script > |
あとは、グローバルメニューの所のulなどにgmenuのid名をつけて
activeクラスがつくので、CSSで装飾すればOKです!!
ルートドメインから2階層目 ○○○.com/○○○/△△△ の△△△ 部分で判定し、activeのclassを付けたい場合は、こちらをご参考ください
↓
http://www.tam-tam.co.jp/tipsnote/javascript/post2775.html
関連記事はこちら!
スポンサーリンク