document.write("Text to display.");
Unfortunately, the document.write method will overwrite all the text on your page. As W3Schools said, it is only for testing. A much more useful method is document.getElementById. document.getElementById enables you to update or change the text in an element easily without affecting the rest of your page, as shown below.