[Solved] How to pass innerHTML of an element to an event handler attribute [closed]
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> solved How to pass innerHTML of … Read more