how to add active class in ul li using javascript 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";
}