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

98
Visualizações
React DOM Manipulation

Let me explain what my code does first. In mn there are some elements and whenever I hover the element inside it, it will add the active class (basically just change the text's color and leave the color there until I hover another element).

When I click the img which is just the logo, I expect it will remove the active class, but I don't know how to make the function, my problem is the mn is an array so I gotta iterate and make a condition or something that I don't really get the idea.

Can anyone help me? thanks before, appreciate any kinda helps

useEffect(() => {
    const mn = document.getElementsByClassName("mn");
    const logo = document.querySelector(".hd-left");
    const img = logo.getElementsByTagName("img")[0]; 

    Array.from(mn).forEach(
      (el) => {
        if (el.innerText === menuSelected.name) {
          el.classList.add("active");
        } else {
          el.classList.remove("active");
        }
      } 
    ); 
  });
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