The original CodeBubb project which doesn’t work well. See the revised version.
section 1
Two functions are created. The first removes the class of active
from all the li elements. The second add the class of hidden to each section.
The next and main part of the script loops through the 3 links using a forEach()
method. An event listener is added to each link and when a click event is fired several things happen. First the two functions (above run)...
section 2
.. Next the parent of the link that has been clicked, that is the li element, has the active class added to it.
Another variable, inside this forEach()
block is created which selects the section that has been clicked using link.hash
.
section 3
Dolor sit amet consectetur adipisicing elit. Quia blanditiis aliquid, sed labore ducimus earum ullam ipsum assumenda.
Alias ea harum tempore nulla distinctio nostrum ipsam! Doloremque eaque ratione suscipit odio! Numquam quod earum reprehenderit cum!