Document.getElementById (..), why the value you get here is null (see figure)

The document.write above

has been written out and the page is gone.


do not use document.write, to use console.log, to check the results in developer tools


it is best to use console.log ()


1.js code is best placed in front of the body closing tag, that is, at the bottom of body,
2. document.getElementById (""). Write () will redraw the entire page. " You can choose to use document.getElementById (""). InnerHTML () ) instead of document.getElementById (""). Write () output,


change to console.log ()


this redrawing


DOM tree is gone.

Menu