Struggling with Sub Menu Script

I'm trying to make my sub menu collapsible, but can't get the code to do what I need it to do. the CSS is pretty large but this troubleshooting should be limited to the section "/* primary-header */". anyone know why I can't get the sub menu list to display as block on click? https://codepen.io/tvu1313/pen/LYXYVjq
2 Replies
Mannix
Mannix2y ago
are you trying to use jquery what's up with the $ ??
nav.addEventListener('click', (e)=>{
e.target.closest('.has-sub').querySelector('ul').classList.toggle('show')
e.target.closest('.has-sub').querySelector('a span').classList.toggle('rotate')
})
nav.addEventListener('click', (e)=>{
e.target.closest('.has-sub').querySelector('ul').classList.toggle('show')
e.target.closest('.has-sub').querySelector('a span').classList.toggle('rotate')
})
this should do the job and in css add
.show{
display:block;
}
.show{
display:block;
}
https://codepen.io/MannixMD/pen/abQbBMX
WithMyTes…
WithMyTes…OP2y ago
Thank you!
Want results from more Discord servers?
Add your server