var base_url = '';

JavaScript Display Possibilities

JavaScript can "display" data in different ways and here we discuss innerHTML and document.write.

  • Writing into an HTML element, using innerHTML.
  • Writing into the HTML output using document.write().


Using innerHTML

To access an HTML element, JavaScript can use the document.getElementById(id) method. The id attribute defines the HTML element. The innerHTML property defines the HTML content:


Using document.write()

For testing purposes, it is convenient to use document.write():

The write() method writes HTML expressions or JavaScript code to a document. The write() method is mostly used for testing: If it is used after an HTML document is fully loaded, it will delete all existing HTML.



Write some text directly to the HTML document, with a new line after each statement (using <br>):

document.write("Hello World! <br>");
document.write("Have a nice day!");


Write HTML elements with text directly to the HTML document:???

document.write("<h1>Hello World!</h1><p>Have a nice day!</p>");


Write the Date object directly to the HTML:


Contact Details

Mobile Number :
9891 222 738,
9891 50 1300

E-mail :

ADDRESS: H-17 / 263, First Floor,Sector 7,
Near Rohini West Metro Station,
Opposite Metro Pillar No. 425
Rohini, Delhi - 110085

Working hours

Day Timing
Monday To Friday 8:00 Am To 7:00Pm
Saturday 10:00 Am To 6:00Pm