DOM:range.surroundContents
From MDC
Contents |
[edit] Summary
Moves content of a Range into a new node, placing the new node at the start of the specified range.
[edit] Syntax
range.surroundContents(newNode);
- newNode
- a Node
[edit] Example
var range = document.createRange();
var newNode = document.createElement("p");
range.selectNode(document.getElementsByTagName("div").item(0));
range.surroundContents(newNode);
[edit] Notes
surroundContents is equivalent to newNode.appendChild(range.extractContents()); range.insertNode(newNode). After surrounding, the boundary points of the range include newNode. (Previously hindered by bug 135928.)