JavaScript Output Example

JavaScrip can find the innerText , innerHTML and set innerHTML  , innerText of any HTML element

 JavaScript have many property learn in letter chapter

1 - find innerHTML 

<DOCTYPE html>


<title> get innerHTML </title>



<h2 id =" demo01"> This is heading tag </h2>

<p class="demo02"> This is paragraph tag </p>


/************** Target innerHTML of h2 heading tag  by id **************/

 var text = document.getElementById("demo01").innerHTML;


/* ********* Target innerHTML of paragraph tag *****************/

var demoText = document.getElementsByClassName("demo02");





Try above code

Target innerHTML by TagName


<p> this is first paragraph</p>

<p> this is second paragrpg </p>


/**** ************* Target innerHTML by TagName ***************/

var text = document.getElementsByTagName("P");





Try above code

maximum time developer use document.getElementById("demo").innerHTML

document.getElementById is case sensitive