Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda