jqueryinputonchange

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


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


Solution

  • You can use .change()

    $('input[name=myInput]').change(function() { ... });
    

    However, this event will only fire when the selector has lost focus, so you will need to click somewhere else to have this work.

    If that's not quite right for you, you could use some of the other jQuery events like keyup, keydown or keypress - depending on the exact effect you want.