I'm trying to understand the logic in this codepen https://codepen.io/tutsplus/pen/bGVPVrY
and I'm confused by how classList is being used to add/remove the active class.
- variable menu is defined by const menu = document.querySelector(".menu");
- In HTML, class .menu is applied to the top ul element
- It seems to me that the code menu.classList.add("active"); is adding the class "active" to the ul element
- But in the codepen CSS, it appears to be added to <li class="item"> a child of menu.
I believe the ul element cannot be show/hide toggled directly, because it needs to remain displayed for non-mobile windows. I don't see that classList will recursively search children.
The codepen works so I'm missing something.