document.addEventListener('DOMContentLoaded', function () { const menuItems = document.querySelectorAll('.et_mobile_menu .menu-item-has-children a'); menuItems.forEach(function (item) { item.addEventListener('click', function (e) { e.preventDefault(); // 阻止默认链接行为 const parent = this.parentElement; // 切换 "open" 类,显示或隐藏子菜单 if (parent.classList.contains('open')) { parent.classList.remove('open'); } else { parent.classList.add('open'); } }); }); });