Is it possible to get the word under the mouse cursor in a <textarea>
?
I have seen this question asked many times regarding text in <p>
tags or similar html output tags, such as here, but the <span>
based solution doesn't work with a <textarea>
, for obvious reasons.
One approach I have considered is to fire a jQuery click()
event to place the cursor and then use something like Tim Down's answere here to get the current word based on the cursor location. But a click()
event doesn't seem to place the cursor at all.
So that answer would be sufficient as well. How do I mimic a click event within a <textarea>
so as to place the cursor at the current mouse position?