$(function () { let hoverTimer; $('.gnb > li').on('mouseenter focusin', function () { const $target = $(this); clearTimeout(hoverTimer); hoverTimer = setTimeout(() => { $('.gnb > li').removeClass('active'); $target.addClass('active'); }, 120); }); $('.gnb > li').on('mouseleave', function () { clearTimeout(hoverTimer); hoverTimer = setTimeout(() => { $(this).removeClass('active'); }, 80); }); // 헤더 전체 영역 밖으로 나가면 닫힘 $('.header').on('mouseleave', function () { $('.gnb > li').removeClass('active'); }); });