var base_url = 'https://www.bapugraphics.com/';

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:

Example:

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.

Example:

Example

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!");

Example

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

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

Example

Write the Date object directly to the HTML:

document.write(Date());

Contact Details

Mobile Number :
9891 222 738,
9891 50 1300

E-mail : contactbapugraphics@gmail.com

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