In this example document.write()
removes all HTML elements fully loaded.
<!DOCTYPE html> <html> <body> <h1>My First Web Page</h1> <p>My first paragraph.</p> <button type="button" onclick="myFunction()">Click me!</button> <script> function myFunction() {/*from w w w.ja v a 2s .co m*/ document.write("Hello World"); } </script> </body> </html>