// キャリア採用ローカルナビ_ページアクティブCSSクラス付与処理 $(document).ready(function() { navList = $("#NavCareer__ul").find("a"); navList.each(function() { if ($(this).attr("href") === ('/corporate/bil/recruit/career/index.aspx')) { // キャリア採用TOPの場合は完全一致のみ if (location.pathname === $(this).attr("href")) { $(this).addClass("on"); } } else { // キャリア採用TOP以外の場合は前方一致(配下ページも含めるため) matchPath = $(this).attr("href").replace('index.aspx', ''); if (location.pathname.indexOf(matchPath) === 0) { $(this).addClass("on"); } } }); });