insertNode
Summary
Inserts a Node into the start of a Range object.
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
Mozilla Developer Network : [Range.insertNode Article]
Microsoft Developer Network: [insertNode Method Article]