getRangeAt
Summary
Returns a specified Range from a selection. The Range is specified by an index and cannot be greater than the number that is returned by rangeCount.
Method of dom/Selectiondom/Selection
Syntax
var range = selObj.getRangeAt(/* see parameter list */);
Parameters
index
- Data-type
- Number
The zero-based index of the range to return. A negative number or a number greater than or equal to rangeCount will result in an error.
Return Value
Returns an object of type RangeRange
The range object that will be returned.
Examples
var ranges = [];
var selObj = window.getSelection();
for(var i = 0; i < selObj.rangeCount; i++) {
ranges[i] = selObj.getRangeAt(i);
}
/* Each item in the ranges array is now
* a range object representing one of the
* ranges in the current selection */
Notes
Remarks
Currently only Gecko supports multiple or disjointed selections.
Syntax
Standards information
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 7.6.1
Attributions
Mozilla Developer Network : [Selection.getRangeAt Article]
Microsoft Developer Network: [getRangeAt Method Article]