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

310
Vistas
If statement to make a button appear/disappear based on the results of game

I have 1v1 browser games on my website & I'm trying to make a button show up for the winner & not show up for the loser on a pop-up modal in the post-game. I'm specifically targeting the "Claim Prize" button on the pop-up" Pop-up Modal "Claim Prize"

HTML for the Button:

  <button class="button button--secondary button--small modal__button"
  data-button="claim">
  Claim Prize
</button>

Js used to define the winner.

function endGame() {
  if(!isGameOver) return;
  let text;
  if(scores.player > scores.opponent) 
    text = TEXTS.win;
  else if(scores.player < scores.opponent)
    text = TEXTS.lose;
  else
    text = TEXTS.draw;
  
  text += `<br> Scores: ${scores.player} - ${scores.opponent}`;

  showEndScreen(text);

Current if statement to attempt to make it show only for the winner:

<script>
  var theyLost = (TEXTS.Win)
  if (theyLost) true;
  document.getElementById("claim").style.display="none";
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Not sure if this will work, but perhaps you can try directly making the button visible if the player wins:

function endGame() {
  if(!isGameOver) return;
  let text;
  if(scores.player > scores.opponent){
    text = TEXTS.win;
    document.getElementById("claim").style.display="none";
  }else if(scores.player < scores.opponent){
    text = TEXTS.lose;
  }else{
    text = TEXTS.draw;
  }
  text += `<br> Scores: ${scores.player} - ${scores.opponent}`;

  showEndScreen(text);
}
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