/* 카테고리 드롭다운 메뉴 js */ // 드롭다운 메뉴를 토글하는 함수 function toggleDropdown(id) { var $dropdownContent = $('#' + id); // 현재 드롭다운이 열려 있는 경우 if ($dropdownContent.hasClass('show')) { // 현재 드롭다운이 열려 있는 경우, 닫기 $dropdownContent.stop(true, true).slideUp().removeClass('show'); } else { // 다른 드롭다운을 닫기 $('.dropdown-content').each(function() { if ($(this).hasClass('show')) { $(this).stop(true, true).slideUp().removeClass('show'); } }); // 현재 드롭다운을 열기 $dropdownContent.stop(true, true).slideDown().addClass('show'); } } // 페이지 클릭 시 드롭다운 닫기 window.onclick = function(event) { // 클릭된 요소가 'cate_dropdown' 또는 그 자식 요소가 아닌 경우 if (!$(event.target).closest('.cate_dropdown').length) { var $dropdowns = $('.dropdown-content'); $dropdowns.each(function() { if ($(this).hasClass('show')) { $(this).stop(true, true).slideUp().removeClass('show'); } }); } }