How do I implement onchange of <input type="text"> with jQuery?

omg picture omg · Sep 18, 2009 · Viewed 570.8k times · Source

<select> has this API. What about <input>?

Answer

iPadDeveloper2011 picture iPadDeveloper2011 · Sep 27, 2012

As @pimvdb said in his comment,

Note that change will only fire when the input element has lost focus. There is also the input event which fires whenever the textbox updates without it needing to lose focus. Unlike key events it also works for pasting/dragging text.

(See documentation.)

This is so useful, it is worth putting it in an answer. Currently (v1.8*?) there is no .input() convenience fn in jquery, so the way to do it is

$('input.myTextInput').on('input',function(e){
 alert('Changed!')
});