Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!