Determine which DOM elements the current text selection contains

Posted by sonofdelphi on Stack Overflow See other posts from Stack Overflow or by sonofdelphi
Published on 2010-03-27T12:49:14Z Indexed on 2010/03/27 12:53 UTC
Read the original article Hit count: 364

Filed under:
|
|

I want to be able to find out which DOM elements are present in the text currently selected by the user in the browser.

document.getSelection() would get us the currently selected text. But how can we determine which DOM elements are contained in this text selection?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dom