Determine which DOM elements the current text selection contains
- by sonofdelphi
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?