Why does this code do not works?
in theory it seems to do instead… but no.
let hafigli_liv2 = appendix_wrap.querySelectorAll('ul.ul-submenu');
hafigli_liv2.forEach(ul_li_liv2 => {
ul_li_liv2.addEventListener("click", (lk_liv2) => {
const link_liv2 = lk_liv2.target.closest('ul.ul-submenu li.menu-item-has-children a');
this.preventDefault(); //evita che cambi pagina
});
});
The logic is that i click in A element inside some UL and LIs and ULs and LIs and it has to not open the link.
Please help