Hi, folks,
As I understand things, the $.selection() function will give me the start and end points of a selection relative to the parent element's $.text() when what I need is to find the element and offset containing those points instead.
Consider the markup
<div id="sample"
<p>This is a test.</p>
<p>This is a second <em>test</em>.</p>
<p>This is a test.</p>
<p>This is the <span class="foo">final</span> test.</p>
</div>
Say, for example, my user clicks between the e and s of the second "test" and drags the mouse, releasing it between the n and a of "final". Calling $.selection('#sample') would return an object with {start: 34, end: 67, width: 33}. I need to be able to determine that that start position is two characters from the start of the content of that em element, and the endpoint is 3 characters from the start of the span.foo element.
How would I do that?