Is it possible to get a word under the mouse cursor in `<textarea>`?

Is it possible to get the word under the mouse cursor in <textarea>?

I have asked this question many times regarding text in tags <p>or similar html output tags such as here , but <span>for the obvious reasons , the solution doesn’t work with <textarea>.

One approach that I examined is to fire a jQuery event click()to position the cursor, and then use something like Tim Down answere here to get the current word at the cursor location. But the event click()does not place the cursor at all.

Thus, an answer will be sufficient. How do I simulate a click event inside <textarea>to place the cursor at the current mouse position?

+2
source share
1 answer

You could take a look at HTML5 CONTENT EDITABLE , this will help you combine the first link you gave in your question and get your solution

0
source

Source: https://habr.com/ru/post/1661422/


All Articles