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

186
Visualizações
How to trigger button on html file when else statement condition is met on .js file

I have had a play around with this code which essentially automatically presses the reset button in the html file when the word is guessed correctly, but I cannot get it to work, the id of the button is reset. It is a guessing game, I want it to reset automatically when the word is guessed. The two $ scripts are my attempt at getting this to work

get statusMessage() {
if (this.status === 'playing'){
return `Nice try! The word was "${this.word.join('')}"`
    return `Guesses left: ${this.remainingGuesses}`
} else if (this.status === 'failed') {   
streak.innerHTML = 0
    return `Nice try! The word was "${this.word.join('')}"```

} else { 
streak.innerHTML ++
return 'Great work! You guessed the word!'
$('#reset').trigger('click');
$('#reset').click();
}

}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

$('#reset').click(); will work if you write it before return statement like this:

 else { 
    streak.innerHTML ++
    $('#reset').click();
    return 'Great work! You guessed the word!'
 }
about 4 years ago · Juan Pablo Isaza 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