Babak Mehrabi
Babak Mehrabi

Reputation: 2275

Finding each change for input in jquery

I have an input in html. I want to be aware on each changing on its content. I know that there is .change function in jquery. But it triggers when you focus on/out the input. I want when user typing in input, for each letter a function will be called. Is there any way to it?

Upvotes: 0

Views: 95

Answers (2)

Ricardo Lohmann
Ricardo Lohmann

Reputation: 26320

How about use input event ? It's not a cross browser way but it should do the trick.
It triggers when the text has been changed, so you can navigate thrue arrow keys and it won't be triggered.

demo

Or you can store the last input text and compare with the actual on keyup for a cross browser way.

References: - https://developer.mozilla.org/en/DOM/DOM_event_reference/input

Upvotes: 0

kei
kei

Reputation: 20471

$("#yourinput").on("keyup",function(){
   //do stuff here
});

Upvotes: 1

Related Questions