What is the outerHTML property and how does it work ?


outerHTML is a property of a node element that permits to

outerHTML replaces the entire target element with the returned content while innerHTML puts the content inside the target element .


let htmlFragment = "<body><p>Replacing the whole body node content with a paragraph</p></body>";
document.body.outerHTML += htmlFragment

If you want to insert a HTML fragment and not delete the actual tree, you can use InsertAdjacentHTML


script elements inserted using outerHTML do not execute when they are inserted. 1)

Discover More
DOM - Child Nodes of a Node

Child Nodes of an element in the dom tree Via child selector, you can select element that are child of another element. The childNodes property of an element returns a collection of child Node....
What is the innerHTML property and how does it work ?

innerHTML is a property of a node element that permits to set the whole descendants of this node with an HTML fragment outerHTML HTML fragmentInsertAdjacentHTML script elements inserted using...

Share this page:
Follow us:
Task Runner