+ 1
How do i change the value in a variable when I on a button?
2 Answers
0
<div id="game"> <button onClick="user(rock)">Rock</button> <button onClick="user(paper)">Paper</button> <button onClick="user(scissors)">Scissors</button> <div id="result"></div> <br> <br> <button onClick="test()">DEBUG</button> </div>
and this in .js file.
var user = "none"; function user(choice){ var user = choice; } function test(click){ alert("You chose " + user); }
0
here example i hope i will help you