Skip to content
On this page

제이쿼리 메뉴 액티브

제이쿼리 메뉴에 보면 액티브 혹은 온 처리 하는 방법은

아래 소스 참고 하면 된다.

js
$('#topNavbar li a').each(function (ele,val) {
    let path = window.location.href.replace(/\/+$/, '');
    if($(val).attr('href') === decodeURIComponent(path)) {
        $(this).parent().addClass('active');
    }
});

여기서 path 조건문이 문제가 된다면 이렇게 하면된다.

js
let something_url;

if(g5_bo_table) {
    something_url = '/'+g5_bo_table;
}else {
    something_url = window.location.pathname;
}

게시판 조건문을 넣어주면된다. 이건 그누보드에만 해당 된다.