Button doesn't show after [removed]

后端 未结 2 1222
悲&欢浪女
悲&欢浪女 2021-01-25 12:53

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

相关标签:
2条回答
  • 2021-01-25 13:11

    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.

    0 讨论(0)
  • 2021-01-25 13:13

    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.

    0 讨论(0)
提交回复
热议问题