[Solved] How to pass innerHTML of an element to an event handler attribute [closed]
[ad_1] You are selecting all the buttons with the code and thus not getting the correct / selected value: var userChoice = document.getElementsByTagName(‘button’).innerHTML; What you could try is to alter the gameMechanism function function gameMechanism(element) { var userChoice = element.innerHTML; } and then change the html to: <button id=”Rock” onclick=”gameMechanism(this);”>Rock</button> [ad_2] solved How to pass … Read more