I am trying to make a navigation menu I did all the HTML and CSS when come to javascript I am struck in the middle I am able to add a class to the
You could use classList methods to add, remove, or toggle.
First remove class name from previous one:
// assuming there's only one with such class name
// otherwise you need querySelectorAll and a loop
document.querySelector('.active').classList.remove('active')
Then add it to the new element:
e.target.classList.add('active')