This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

insertNode

Summary

Inserts a Node into the start of a Range object.

Method of dom/Rangedom/Range

Syntax

 newNode.insertNode(/* see parameter list */);

Parameters

oNode

Data-type
DOM Node

The new node to insert.

Return Value

No return value

Examples

var range = document.createRange();
newNode = document.createElement("p");
newNode.appendChild(document.createTextNode("New Node Inserted Here"));
range.selectNode(document.getElementsByTagName("div").item(0));
range.insertNode(newNode);

Notes

If the container is a node of type Text, insertNode splits the text node, and inserts newNode between the resulting two text nodes. If newNode is a document fragment, the children of the document fragment node are inserted rather than the newNode itself.

Related specifications

DOM
Living Standard
Document Object Model (DOM) Level 2 Traversal and Range
W3C Recommendation

Attributions