Reputation: 1475
I have a content editable div that has pre-existing text. This element is by default set to false (not editable), and on double click I am changing the content editable attribute to true and then focusing on the div element.
This is currently selecting all the pre-existing text inside the content editable div, but I would prefer for the caret to be inserted at the closest text DOM node from the mouse cursor position when the double click event fired.
Needing only to support webkit, and having jQuery as a tool if needed, what is the most straight forward way to do this?
Upvotes: 0
Views: 593
Reputation: 9705
If you only need to support chrome you can use document.caretRangeFromPoint
Upvotes: 1