Consider the following code:
<div contenteditable="true">One two th|ree <span>four</span> five six seven</div>
Let's imagine that the caret (bliking cursor) is placed on the word "three", between the letters "h" and "r". What is the best (cross-browser) way to get the positions of the word beginning and end?
My goal is to determine if the caret is closer to the start or end of the word and move caret then to the one that's closer. So for my provided example, it should move the caret to here:
<div contenteditable="true">One two |three <span>four</span> five six seven</div>
I would be best if I could have a cross-browser (including Opera and IE) solution.