javascript main section remove active class code example
Example: 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";
}