I need help with toggling the "li-active" class on my navigation bar links. Currently, when I click on a link, the "li-active" class is transferred from the previous link to the newly clicked link instead of removing it first. Can someone please assist me in solving this issue? Thank you!
<li data-id="0" id="mercury" class="navbar__links--li">
<div class="inner-div">
<div class="mercury-oval"></div>
MERCURY
</div>
<svg
class="svg"
xmlns="http://www.w3.org/2000/svg"
width="6"
height="8"
>
<path fill="none" stroke="#FFF" opacity=".4" d="M1 0l4 4-4 4" />
</svg>
</li>
<li data-id="1" id="venus" class="navbar__links--li">
<div class="inner-div">
<div class="venus-oval"></div>
VENUS
</div>
<svg
class="svg"
xmlns="http://www.w3.org/2000/svg"
width="6"
height="8"
>
<path fill="none" stroke="#FFF" opacity=".4" d="M1 0l4 4-4 4" />
</svg>
</li>
<li data-id="2" id="earth" class="navbar__links--li li-active">
<div class="inner-div">
<div class="earth-oval"></div>
EARTH
</div>
<svg
class="svg"
xmlns="http://www.w3.org/2000/svg"
width="6"
height="8"
>
<path fill="none" stroke="#FFF" opacity=".4" d="M1 0l4 4-4 4" />
</svg>
</li>
<li data-id="3" id="mars" class="navbar__links--li">
<div class="inner-div">
<div class="mars-oval"></div>
MARS
</div>
<svg
class="svg"
xmlns="http://www.w3.org/2000/svg"
width="6"
height="8"
>
<path fill="none" stroke="#FFF" opacity=".4" d="M1 0l4 4-4 4" />
</svg>
</li>
<li data-id="4" id="jupiter" class="navbar__links--li">
<div class="inner-div">
<div class="jupiter-oval"></div>
JUPITER
</div>
<svg
class="svg"
xmlns="http://www.w3.org/2000/svg"
width="6"
height="8"
>
<path fill="none" stroke="#FFF" opacity=".4" d="M1 0l4 4-4 4" />
</svg>
</li>
<li data-id="5" id="saturn" class="navbar__links--li">
<div class="inner-div">
<div class="saturn-oval"></div>
SATURN
</div>
<svg
class="svg"
xmlns="http://www.w3.org/2000/svg"
width="6"
height="8"
>
<path fill="none" stroke="#FFF" opacity=".4" d="M1 0l4 4-4 4" />
</svg>
</li>
<li data-id="6" id="uranus" class="navbar__links--li">
<div class="inner-div"&...
.li-active {
@include desktop {
border-top: 1px solid red;
}
}
menuBtn.forEach((li) => {
li.addEventListener("click", (e) => {
menuBtn.forEach((el) => el.classList.remove("li-active"));
e.target.classList.add("li-active");
});
});