You can do like that. Just add a class like “active” to the clicked element and remove it from others
var menu = document.querySelector("#menu");
for(var i = 0; i < menu.children.length; i++){
menu.children[i].onclick = function (event){
document.querySelector(".active").className = "";
event.target.className = "active";
}
}