createRange
Summary
Creates an empty Range instance object that has both of its boundary points positioned at the beginning of the document. After a Range is created, you must set its starting and ending boundary points before you can make use of most of its methods.
Method of dom/Documentdom/Document
Syntax
var range = document.createRange();
Return Value
Returns an object of type DOM NodeDOM Node
An empty Range instance object.
Examples
//create a document range
var myRange = document.createRange();
//set starting and ending boundaries using predefined objects and variables
myRange.setStart(startNode, startOffset);
myRange.setEnd(endNode, endOffset);
Related specifications
- DOM Level 2 Traversal and Range
- Recommendation
Attributions
Mozilla Developer Network : Article
Microsoft Developer Network: [Windows Internet Explorer API reference Article]