innerHTML in JS is bidirectional: Gets the contents of an object or inserts content into an object;
such as: <div id= "AA" > This is Content </div>, we can pass document.getElementById (' AA '). InnerHTML to get the embedded content of an object with ID AA;
You can also insert content on an object, such as document.getElementById (' abc '). Innerhtml= ' This is the inserted content '; This allows you to insert content into an object with an ID of ABC
For the innerHTML property, almost all elements have a innerHTML property, which is a string that sets or gets the HTML that is inside the object's start and end tags. (Gets the contents of the beginning and end of the current HTML tag)
Grammar
Tablerowobject.innerhtml=html
Instance
The following example returns the inner HTML for the table row:
<script type= "Text/javascript" >
function getinnerhtml () {
Alert (document.getElementById ("TR1"). InnerHTML);
}
</script>
<body>
<table border= "1" >
<tr id= "TR1" ><td>Firstname</td><td>Lastname</td></tr>
<tr id= "TR2" ><td>Peter</td><td>Griffin</td></tr>
</table>
<input type= "button" onclick= "getinnerhtml ()" value= "Alert InnerHTML of Table row"/>
</body>
What does the innerHTML in JavaScript mean, and how do you use it?