removeRange
Summary
Removes a range from a selection.
Method of dom/Selectiondom/Selection
Syntax
var result = selObj.removeRange(/* see parameter list */);
Parameters
range
- Data-type
- Range
Range to remove.
Return Value
Returns an object of type NumberNumber
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Examples
/* In gecko Programmaticaly, more than one range can be selected.
* This will remove all ranges except the first. see Compatibility Notes below */
selObj = window.getSelection();
if(selObj.rangeCount > 1) {
for(var i = 1; i < selObj.rangeCount; i++) {
selObj.removeRange(selObj.getRangeAt(i));
}
}
Notes
Remarks
Windows Internet Explorer 9-11 does not currently support multiple or disjointed selections in standards mode.
Syntax
Standards information
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 7.6.1
Attributions
Mozilla Developer Network : [Selection.removeRange Article]
Microsoft Developer Network: [Windows Internet Explorer API reference Article]