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

157
Visualizações
How to re-use animation each time element.textContent is changed?

this is pretty simple, but I have javascript generating textContent changes for a rock paper scissors project. The fade in animation only works on the first event.

I've tried searching the web for solutions. I tried element.removeChild(element.firstChild); right before each textContent change, but it didn't work I think because the textContent is not considered a node. I tried deleting the textContent right before each change, which also didn't work. Any help is much appreciated!

Javascript snippet:

 if ((playerPick === "Rock" && computerPick === "Scissors") || (playerPick 
        === "Paper" && computerPick === "Rock") || (playerPick === "Scissors" && 
        computerPick === "Paper")) {
            playerWins++;
            rounds++;
            round.textContent = `You win! ${playerPick} beats ${computerPick}!`;
        }

CSS snippet:

.narrative-banner {
        text-align: center;
        color: white;
        font-size: 2.2em;
        font-weight: 700;
        padding: .2em;
        padding-top: .8em;
        animation: fade-in 5s;
}
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