javascript remove active class code example
Example 1: first remove active class from classlist and append to current element using javascript
function myFunction(e) {
if (document.querySelector('#navList a.active') !== null) {
document.querySelector('#navList a.active').classList.remove('active');
}
e.target.className = "active";
}
Example 2: remove active class from all li javascript
<script src="https://www.w3schools.com/lib/w3.js"></script>
<ul>
<li class="ready">
</li>
<li class="ready">
</li>
<li class="ready">
</li>
</ul>
<button onclick="w3.removeClass('li','ready');"></button>