I made a rock, paper, scissors game and in the program, I have a button that should come up but it never does, It keeps giving me an error that says, \"Uncaught TypeError: Canno
When you use document.write
, it will display its content by overwriting all the DOM elements.
So you need to use innerHtml
for displaying the contents keeping your DOM Alive.
The document.write
will overwrite your entire DOM, so the button you initialized onload will actually be overwritten by the contents of your document.write
.
However, if you do not want your content to disappear, I suggest making a new div
and using document.getElementById("div_id").innerHTML
in place of your document.write()
commands in order to save the button.