Javascript Reference
Categories: selection

javascript selection removeRange( )

@March 15, 2008, 1:22 a.m.
removeRange( )Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM n/a  

removeRange(rangeReference)

  

Removes a single Range object from the current selection (not from the document tree). If you have a multiple-range selection, you can iterate through all Range objects, inspect each for some criterion, and delete the one(s) you want with the following sequence:

var oneRange;
var sel = window.getSelection( );
for (var i = 0; i< sel.rangeCount; i++) {
    oneRange = sel.getRangeAt(i);
    if (oneRange. someProperty == someDiscerningValue) {
        sel.removeRange(oneRange);
    }
}
 
Parameters
 
  • Reference to one of the Range objects previously added to the current selection.
 
Returned Value

None.


Powered by Linode.