// 障がい者採用ローカルナビ_ページアクティブCSSクラス付与処理 document.addEventListener('DOMContentLoaded', function() { //PC navList_pc = document.getElementById('HeaderRec__wrap__right__ul').querySelectorAll('a'); navList_pc.forEach(function(nav) { url = nav.getAttribute('href'); if (url === ('/corporate/bil/recruit/welfare/index.aspx')) { // TOPの場合は完全一致のみ if (location.pathname === url) { nav.classList.add('on'); } } else { // TOP以外の場合は前方一致 matchPath = url.replace('index.aspx', ''); if (location.pathname.indexOf(matchPath) === 0) { nav.classList.add('on'); } } }); //スマホ navList_sp = document.getElementById('HeaderRec__wrap__ul').querySelectorAll('a'); navList_sp.forEach(function(nav) { url = nav.getAttribute('href'); if (url === ('/corporate/bil/recruit/welfare/index.aspx')) { // TOPの場合は完全一致のみ if (location.pathname === url) { nav.classList.add('on'); } } else { // TOP以外の場合は前方一致 matchPath = url.replace('index.aspx', ''); if (location.pathname.indexOf(matchPath) === 0) { nav.classList.add('on'); } } }); });