1

I'm making a blackjack game and have a <button id='standBtn'>Stand</button>. I want to get this button "clicked" automatically if(score(myCards) === 21){/* click Stand button */}

brigysl
  • 179
  • 1
  • 14

1 Answers1

1

You need to use .click() function, like this:

if(score(myCards) === 21){
    document.getElementById('standBtn').click();
}

Or simply,if you use jquery

if(score(myCards) === 21){
    $('#standBtn').click();
}
Mihai Alexandru-Ionut
  • 47,092
  • 13
  • 101
  • 128