Get word in textarea above mouse

I have an HTML element. My goal is when the mouse over the word in the text box I need to get the word and do something with it. How can this be implemented? What event should I use?

+4
source share
1 answer

As I know, you cannot do this.

Only you can do this, wrap each element as <span>, and add a mouse event to all elements <span>.

<div class="spanhover"><span>Wrap</span><span>all</span><span>elements</span></div>

<script>
$(document).ready(function () {
  $('.spanhover span').bind('mouseenter', function () {
    alert($(this).html() + " is your word");
  });
});
</script>
+4
source

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


All Articles