innerHTML is a DOM node's property that gets or sets the inner HTML code of an HTML element. It is commonly used in Javascript to dynamically change or read from a page.
innerHTML is a DOM node's property that gets or sets the inner HTML code of an HTML element. It is commonly used in JavaScript to dynamically change or read from a page.
Syntax to get innerHTML
var content = element.innerHTML; /* To get the inner HTML of an element */
where,
content
contains the serialized HTML code describing all of the element's descendants.
Syntax to set innerHTML
element.innerHTML = content; /* To set the inner HTML of an element */
Removes all of element's children, parses the content
string and assigns the resulting nodes as children of the element.