I need the position or lets say the start and endoffset of a selected text inside of a html container (containing also html). For example:
<span id="text-for-selection">
<h1>Heading</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.</p>
<p>Aenean massa.</p>
<p>Aenean massa.</p>
<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. </p>
</span>
If i select the first "Aenean massa." now, I need to know the position of the first selected letter inside the text-for-selection container (including the html tags!!) - not only inside the <p>
tag.
I tried to search for it, but what if i select the second one, which one to choose?
I know how to get selected text or how to add html to the selection or how to replace the selected text.
But i don't know how to get the range / offset inside the span container.
Any ideas?
`s and `
`? Why not ``?
– Tony Dinh Mar 24 '14 at 16:42