function - JavaScript/HTML Code In Variables? -
i designing monopoly style digital game , want dice rolling button tried this:
<button class="bttnrolldice" onclick="diceroll()">roll dice</button><h1 id="rollresults"></h1> <script> function diceroll() { var die1 = math.ceil(math.random() * 7; var die2 = math.ceil(math.random() * 7; document.getelementbyid("rollresults").innerhtml = (die1 + die2); } </script> whenever run code, nothing shows below button. can give me hand? (it might have variables equal js code, if tell me how fix this.)
you missing closing parenthesis on math.ceil functions
<button class="bttnrolldice" onclick="diceroll()">roll dice</button><h1 id="rollresults"></h1> <script> function diceroll() { var die1 = math.ceil(math.random() * 7); var die2 = math.ceil(math.random() * 7); document.getelementbyid("rollresults").innerhtml = (die1 + die2); } </script>
Comments
Post a Comment