Need help creating an array of the first li elements but unsure of how to proceed.
Here is the HTML structure:
<div class="nav">
<ul>
<li>Element 1</li>
<li>Element 2
<ul>
<li>Element 2.1</li>
<li>Element 2.2</li>
<li>Element 2.3</li>
<li>Element 2.4</li>
</ul>
</li>
<li>Element 3</li>
<li>Element 4
<ul>
<li>Element 4.1</li>
<li>Element 4.2</li>
<li>Element 4.3</li>
<li>Element 4.4</li>
</ul>
</li>
</ul>
Looking to target the first li elements of the first ul - element 1, element 2, element 3, element 4. Trying to use querySelectorAll but unsure about the correct syntax without nth-child in CSS.
Here's my JS querySelectorAll code so far:
const allVisibleElements = document.querySelectorAll('');