+ 1

How do i change the value in a variable when I on a button?

27th Aug 2017, 2:26 AM
Samuel
Samuel - avatar
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); }
27th Aug 2017, 5:19 AM
Dor Nachemani
Dor Nachemani - avatar
0
here example i hope i will help you
27th Aug 2017, 5:19 AM
Dor Nachemani
Dor Nachemani - avatar