Event to detect when text in <input> scrolls?

Is there an event that fires when scrolling text inside an <input> -tag? I mean when the text inside is long and you move the input carriage to the end, etc.

There is a scroll event that you can catch in an element when it scrolls in a layout, but thatโ€™s not what I want.

UPDATE: here is the fiddle for checking the events discussed: http://jsfiddle.net/lborgman/L8k5ggnk/3/

+5
source share
2 answers

For this, there is no specific event that will work in all browsers. Firefox scroll event when text "scrolls" by changing the insertion point, but Chrome and probably other browsers do not.

Here is a list of events that can change the insertion point.

  • input
  • keydown
  • keyup
  • focus
  • blur
  • click
  • change
  • paste
  • cut
  • scroll
  • wheel
  • dragover

Binding an event listener to all of these should be enough to respond to a change in the insertion point. I believe the above list is complete, but if I missed something, let me know!

+4
source

Have you tried the Caret plugin ?

You can get the position of the carriage with:

 pos = $(textarea).caret() 

and catch when he changes again. If the latter is different from the first, then you know that the user has moved inside the input.

+2
source

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


All Articles