Javascript Reference
Categories: selection

javascript selection getRangeAt( )

@March 16, 2009, 4:47 a.m.
getRangeAt( ) Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM n/a  

getRangeAt(rangeIndex)

  

Returns a reference to the range within a selection object whose zero-based numeric index matches the passed parameter. For contiguous selections, the parameter should be zero. But for discontiguous selections, the getRangeAt( ) method lets you retrieve each range that had been added to the selection for individual manipulation as a Range object. Use the selection.rangeCount property to derive the number of Range objects contained by the selection object. Invoking the method does not disturb the sequence of ranges within the selection.

 
Parameters
 
  • Zero-based integer index value.
 
Returned Value

Range object reference.

Thank you, I've been searching on the Internet for a long time to find out why I need a range object to get the selected text. This helps me a lot.
searene - 2015-12-09
Thank you for your suggestions. I am going to make updates.
javascript manual - 2009-03-16
The lack of links to things, like the returned object type in this case, makes this site pretty much unusable.

How did you get such high pagerank? Is this site all about SEO? How about making it more useful, then you'd get return visits from developers, because they'd find the information more useful.

Sorry for the hubris, but it's true. If I have to go and search your site again and again to find things that, in this day and age, should be linked to, then it's not of value.

Thanks for reading.
plausible_deniability - 2009-03-16

Powered by Linode.