There's a menu on my website with li
tags containing an a
element for navigation. Everything is working fine, but I'm facing an issue where I need to remove all elements with the class seleccionado
and only add it to the clicked li
. I tried using .remove
to achieve this without success. Is there any other way to accomplish this?
The goal is to remove the class from all elements and then add it only to the li
that was clicked.
clicked(event) {
var el = document.getElementsByClassName("detectar");
el.classList.remove("seleccionado");
if(window.location.pathname){
event.path[3].classList.add("seleccionado");
}
}