ひとつ目がファイル名、ふたつ目がURL。
$(window).bind("load", function(){ if(document.URL.indexOf("example.html")) { $('#gNav1').addClass('current'); } }); $(window).bind("load", function(){ if(document.URL.match(/example/)) { $('#gNav1').addClass('current'); } });
それぞれ特定の文字列が入っていた場合に”#gNav1″の要素に”current”というクラス属性を付与しています。
コメント