Assuming there is a mousestop event attached to the entire document, what is the best way to figure out the exact word under the cursor (if there is any text), when the mouse stops moving?
I can get the underlying (jQuery) element from the event handler – $(document.elementFromPoint(e.clientX, e.clientY)) – but then what is next?
So far my idea is to replace all text nodes within hit element with their copy where each word is wrapped in a DOM element (don’t know which one yet) and then call $(document.elementFromPoint(e.clientX, e.clientY)) again to get the element that contains only the word under mouse.
But that seems like a complicated plan and I wonder whether I am missing something simpler.
Well, no magic tricks so far, so here is the dull boring (and yet working) solution:
There are few other subtleties involved (like event ‘noise reduction’, keeping replaced dom context (such as selection) and so forth), but you get the idea.
Here you can learn how set up mousestop event.
EDIT:
Making custom html elements may not be that strait forward in IE (who would have thought?). Check out more here.