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

309
Visualizações
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 Respostas
Responde à pergunta

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 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