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 */}
            Asked
            
        
        
            Active
            
        
            Viewed 60 times
        
    1
            
            
         
    
    
        brigysl
        
- 179
- 1
- 14
- 
                    Try this: `$('#standBtn').click()`. – Mihai Alexandru-Ionut Dec 07 '16 at 19:26
- 
                    2But also.. consider just executing the function that would happen if the user were to click said button. It's a bit weird to "click" the button. – Jordan Soltman Dec 07 '16 at 19:27
1 Answers
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