Document write() Method - use document.write() after an HTML document is fully loaded, will delete all existing HTML. - Javascript DOM

Javascript examples for DOM:Document write

Description

Document write() Method - use document.write() after an HTML document is fully loaded, will delete all existing HTML.

Demo Code

ResultView the demo 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() {/*  w  ww .  java 2 s .c  o  m*/
    document.write("Hello World");
}
</script>

</body>
</html>

Related Tutorials