سؤال

Suppose I have a simple <input type="text">, is it possible to add a Javascript listener to listen for when a user mouseover a typed text inside that input? If so, could I also know exactly which letter (or position in the string) they are currently moused over?

I am willing to use JS frameworks like jQuery to achieve this.

هل كانت مفيدة؟

المحلول

Nope. Letters in an input are not HTML elements. You need HTML elements to have event handlers.

The only way to accomplish this is to hide the input box and have a fake one over top and wrap each individual letter in a SPAN as you type. That way each letter is within an actual HTML element.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top