Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top