How to use DOM Object Write in JavaScript

In this example I am going to explain about DOM Object Write() Method in JavaScript.
  • 2169

JavaScript DOM Object Write() Method

JavaScript Write() method use for write Html expiration or any message on the document. In other word we can say that write() method use for display any type of output or message on the document.

Syntax

document.write()

Example // Simple display a message

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            document.write("Hello Friends");

        }

    </script>

</head>

<body >

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Example // Example with Html element

 

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            document.write("<h2>Hello India</h2>");

        }

    </script>

</head>

<body>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Output

 

 write.gif

 

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.