JavaScript document write() Method Tutorial

In this section we will learn what the document write() method is and how to use it in JavaScript.

What is document write() Method in JavaScript?

The JavaScript document write() method is used to write content (including source codes) to output stream.

This output stream is basically the page that users see!

This means if there’s already a document displayed to users, then calling this method on top of the document will remove the old content and display the new content instead.

For example, using this method we can send a message like “Hello World” to the page.

Or put HTML elements as the argument of this method and they will be rendered on the page.

document write() Method Syntax:

document.write(arg1,arg2,…,argn);

document write() Method Parameters

The function takes one or more arguments and sends all of them to the output stream.

document write() Method Return Value

This function does not return a value.

Example: using document write() Method in JavaScript

See the Pen using document write() Method in JavaScri by Omid Dehghan (@odchan1) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies