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

106
Visualizações
Remove/Add Class on menu hover

I have tried so many ways to simply get a class to change on an image when I hover over a menu item and it is driving me bonkers. If someone can help me get this straight I would appreciate some help... In the end I will have three of these in place, one for Red, Yellow, and Blue... here is what I have for one example...

<script>
const triggerRed = document.getElementsByClassName('gardenBtn');
const redIMG = document.getElementById('gardenMe');
// 👇️ Change
triggerRed.addEventListener('mouseover', function handleMouseOver() {
  list = redIMG.classList;
  list.remove('risoMe');
});
// 👇️ Change back
triggerRed.addEventListener('mouseout', function handleMouseOut() {
  list = redIMG.classList;
  list.add('risoMe');
}); 
</script>

But nothing changes

almost 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I don't see anywhere you declaring list variable. Anyway, if you want to add a class to that element:

list.classList.add('class-name');

if you want to remove a class:

list.classList.remove('class-name');
almost 4 years ago · Santiago Trujillo Relatório
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