Javascript DOM HTML Document write() Method replace loaded content

Introduction

In this example document.write() removes all HTML elements fully loaded.

View in separate window

<!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>



PreviousNext

Related