I have a contenteditable div in which I have several tags (br, b, u, i) and text, and I need to get the caret position relative to the div, including all the tags.
For example:
<div id="h" contenteditable="true">abc<b>def<br>ghi</b>jkl</div>
If the cursor is between g and h, I need the carriage position to be 14. The problem is that the found methods that use treeWalker do not work in this case. Bold tag not found ... perhaps because it is not closed. In addition, I tried several methods, but still no luck.
I need it to work in Firefox. Thanks.
helldrain
source share