Home | Top | Website design | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.


surroundContents Method

Moves content of a Range into a new node.

Syntax

range.surroundContents(newNode);
 

Parameters

newNode a Node

Example

range = document.createRange();
 
newNode = document.createElement("p"):
 
range.selectNode(document.getElementsByTagName("div").item(0));
 
range.surroundContents(newNode);
 

Notes

surroundContents is equivalent to newNode.appendChild(range.extractContents());range.insertNode(newNode). After surrounding, the boundary points of the Range include newNode. (Hindered by http://bugzilla.mozilla.org/show_bug.cgi?id=135928 )

Specification

surroundContents

Home | Top | Website design | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.