function subnav() {
const subnavItem = document.querySelectorAll('.header-nav-list-item.subnav');
window.addEventListener("click", e => {
subnavItem.forEach(item => {
const target = e.target;
if (target === item || target.parentElement === item) {
item.querySelector(".header-nav-list-subnav-menu").style.display = "block";
} else {
item.querySelector(".header-nav-list-subnav-menu").style.display = "none";
}
});
});
}
$(function() {
$(window).on("click", e => {
$('.header-nav-list-item.subnav').each(function() {
const $subMenu = $(this).find(".header-nav-list-subnav-menu");
const isVisible = e.target === this || $.contains(this, e.target);
$subMenu.toggle(isVisible);
// if (!isVisible) $subMenu.hide();
});
});
});