rangeCount
Summary
Returns the number of ranges in a selection
Property of dom/Selectiondom/Selection
Syntax
Note: This property is read-only.
var rangecount = selObj.rangeCount;
Return Value
Returns an object of type NumberNumber
The number of ranges in a selection.
Examples
var selObj=window.selection();
var rangecount=selObj.rangeCount;
Notes
Remarks
Windows Internet Explorer 9-11 does not currently support multiple or disjointed selections in standards mode. This property always returns a 1 with a valid selection. It returns a 0 if removeRange or removeAllRanges have been applied, though calling isCollapsed is recommended instead to detect an empty range.
Before the user has clicked a freshly loaded page, the rangeCount is 0. A user can normally only select one range at a time, so the rangeCount will usually be 1. Scripting can be used (currently) in Gecko to make the selection contain more than 1 range.
Syntax
Standards information
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 7.6.1
Attributions
Mozilla Developer Network : [Selection.rangeCount Article]
Microsoft Developer Network: [rangeCount Property Article]