JavaScript OutPut

Below are the options for displaying the contents using JavaScript:

# window.alert() — Alert box to display data.

# document.write() — Writing into the HTML output.
document.write(5 + 6);
**Note: Using document.write() after an HTML document is fully loaded, will delete all existing HTML.
Adding on button click event  Show Result Then button click will show only the result value on the page.

# innerHTML — Writing into an HTML element.
<p id=”demo” />
document.getElementById(“demo“).innerHTML = 5 + 6;

# console.log() — Writing into the browser console. To see the output activate the browser console with F12, and select “Console” in the menu.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s