Despite my hesitation, I have to ask this question after unsuccessful searches in related articles. In my code, I have 7 nav links all with the same class. Due to the length of the HTML, I am looking for a way to hide contents until the link is clicked, and then have the content disappear when another nav link is clicked to make space for the next one. I would appreciate an answer in vanilla js, as that is what I am currently learning. You can find my pen here.
<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>
This is how my navigation bar looks like.
Please note that I am new to JavaScript. Thank you for your understanding and time.