I did not want to ask this question, but after searching the related articles in here, I have to. My code has 7 nav links all with the same class, and because the html is quite long, I want to be able to hide contents until the link is clicked, and also have the content disappear when another nav link is clicked; allowing space for the next. I would prefer the answer in vanilla js, as that is what i am learning now. Here is a link to my pen please: Codepen
<ul>
<a href="#Hello_World" class="nav-link" onclick='myFunction()'>
<li>Hello World</li>
</a>
<a href="#Introducing_JSX" class="nav-link">
<li>Introducing JSX</li>
</a>
<a href="#Rendering_Elements" class="nav-link">
<li>Rendering Elements</li>
</a>
<a href="#Components_and_Props" class="nav-link">
<li>Components and Props</li>
</a>
<a href="#State_and_Lifecycle" class="nav-link">
<li>State and Lifecycle</li>
</a>
<a href="#Handling_Events" class="nav-link">
<li>Handling Events</li>
</a>
<a href="#Thinking_in_React" class="nav-link">
<li>Thinking in React</li>
</a>
</ul>
Here is an example of my nav bar.
Disclaimer: I am totally a js beginner. Thanks for your patience and time.