js1 [JS] 메뉴 이동시 선택한 메뉴 클릭 유지 되도록 메뉴 이동시 선택한 메뉴가 클릭 유지 되도록 하려면 다음과 같은 코드를 작성하면 됩니다. const menuItems = document.querySelectorAll(".class_nav .class_ul li a");임의의 class_nav를 가진 요소 내부의 class_ul를 가진 요소 내부의 모든 li 요소의 자손인 a요소들을 선택합니다. const currentPath = window.location.pathname;현재 URL에서 도메인 다음에 오는 경로를 가져옵니다. menuItems.forEach(function(link) { const li = link.parentElement; if (link.getAttribute('href') === currentPath) { .. 2024. 5. 29. 이전 1 다음