How to get position from selected text in HTML?
the HTML content is rendered by setting innerHTML. For example 1. 2
is rendered 1. 2
The use is then selecting 2 with text selector.
const start = document.getSelection().anchorOffset
is working fine to get me the position in rendered text. Which is 5 is this case.
But is there some to get the position from HTML content (I think in this case it will be 20)
By the way great article to learn selection