homepage.veen.world/app/static/js/close-submenus.js

22 lines
818 B
JavaScript

document.addEventListener('DOMContentLoaded', () => {
const dropdownSubmenus = document.querySelectorAll('.dropdown-submenu > .dropdown-item');
dropdownSubmenus.forEach((submenu) => {
submenu.addEventListener('click', (event) => {
event.preventDefault();
const targetMenu = document.querySelector(submenu.getAttribute('data-bs-target'));
const allSubmenus = document.querySelectorAll('.dropdown-menu.collapse');
// Schließe alle anderen Submenüs
allSubmenus.forEach((menu) => {
if (menu !== targetMenu) {
menu.classList.remove('show');
}
});
// Toggle des aktuellen Submenüs
targetMenu.classList.toggle('show');
});
});
});