I want to Add a class in these list items but the condition is if I add a (active) class in a particular list item
let getList=document.querySelectorAll("li")
getList.forEach(li=>{
li.addEventListener("click", function(){
li.classList.add("active")
})
})
.list-item{
height:80px;
width:70px;
background-color:black
}
.list-item li{
color:white
}
.active{
border:5px soild blue;
list-style:none;
color:orange;
}
<body>
<ul class="list-item">
<li>Apple</li>
<li>Banana</li>
<li>Orange</li>
</ul>
</body>
The previous active class in list tag must be removed automatically