innerHTML property

JSAny get innerHTML
inherited

The Element property innerHTML gets or sets the HTML or XML markup contained within the element.

More precisely, innerHTML gets a serialization of the nested child DOM elements within the element, or sets HTML or XML that should be parsed to replace the DOM tree within the element.

To insert the HTML into the document rather than replace the contents of an element, use the method Element.insertAdjacentHTML.

The serialization of the DOM tree read from the property does not include — if you want to get a HTML string that includes shadow roots, you must instead use the Element.getHTML or ShadowRoot.getHTML methods. Similarly, when setting element content using innerHTML, the HTML string is parsed into DOM elements that do not contain shadow roots.

So for example <template> is parsed into as HTMLTemplateElement, whether or not the shadowrootmode attribute is specfied In order to set an element's contents from an HTML string that includes declarative shadow roots, you must use either Element.setHTMLUnsafe or ShadowRoot.setHTMLUnsafe.

Implementation

external JSAny get innerHTML;
set innerHTML (JSAny value)
inherited

Implementation

external set innerHTML(JSAny value);