Suppose I have this HTML
<div id="someparent">
Foo
<span id="one">Selection starts anywhere inside here</span>
<span id="two">Selection ends anywhere inside here</span>
<span id="three">Some more text here</span>
Bar
</div>
I want to return the span #one
, and span #two
nodes (so that I can wrap a further span round them*). If foo and bar are the start and end points of the selection, div #someparent
would be returned (twice).
*How to do this would be helpful too even if with jQuery.
This is similar to this question which asks for the single parent of the whole selected text.