So, I searched everything, trying to figure out how to do the following and still not find a solution:
I need to get the text offset for a given HTML element from a click event. This means that if I have the following HTML
<p>This is a really cool paragraph</p>
and the user clicks on the first “a” in the sentence, the text shift will be 8, since the first “a” is at index 8, if we take the “T” in 'This' as index 0.
I need this information so that I can programmatically create a selection of text based on where the user clicks. At the moment, I can track which HTML elements we click on, and therefore I can create this kind of activity at the level of detail at the HTML level, but I would like to have finer control than that.
Thank!
source
share