Definition and usage
The InnerHTML property is used to set or return the HTML content between the specified labels .
Grammar
object.innerhtml = "HTML"; // Set var html = object.innerhtml; // Get
Example 1
Gets the InnerHTML (HTML content) of the paragraph P
<HTML><Head><Scripttype= "Text/javascript">functiongetinnerhtml () {alert (document.getElementById ("Test"). InnerHTML);}</Script></Head><Body><PID= "Test"><FontColor= "#000">Hi Bean Shell www.hi-docs.com</Font></P><inputtype= "button"onclick= "getinnerhtml ()"value= "Tap" /></Body></HTML>
Example 2
Set InnerHTML (HTML content) for paragraph p
<HTML><Head><Scripttype= "Text/javascript">functionsetinnerhtml () {document.getElementById ("Test"). InnerHTML= "<strong> Set HTML content for tags </strong>";}</Script></Head><Body><PID= "Test"><FontColor= "#000">Hi Bean Shell www.hi-docs.com</Font></P><inputtype= "button"onclick= "setinnerhtml ()"value= "Tap" /></Body></HTML>
Example 3: Document.body.innerHTML
<HtmL><Head><Metacontent= "Text/html;charset=utf-8"http-equiv= "Content-type"> <Scripttype= "Text/javascript">window.onload= function(){ varArrli={my friend: ['Wow, haha .','Robust','Farmer Spring'], classmate: ['Coffee','Juice','Wine']}; varN= -1 for(varIinchArrli) {N++; Document.body.innerHTML+= '<ul>'+I+'</ul>'; varul=document.getElementsByTagName ('ul'); for (varJ= 0; J<Arrli[i].length; J++) {ul[n].innerhtml+= '<li>'+Arrli[i][j]+'</li>'; }; } } </Script></Head><Body></Body></HtmL>
JS's InnerHTML