Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
select classes with same "ClassName"

So, what I am trying to achieve is selecting all className that contain "list"

Then whenever one is clicked, it becomes "list active", when clicked next, the "active" is removed from the current list and goes to the next one. something like this first I want to select all the list classes

const list = document.querySelectorAll(".list");

then

function activeList() {
    list.forEach((element) => element.classList.remove("active"));
    this.classList.add("active");
   }

then I want to add a listener to all "list classes"

list.forEach((element) => element.addEventListener("click", activeList));

The problem is this approach does not work on react. any suggestion?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda