I want to handle change event in a text input field. but the event is triggered when the mouse loses focus on element.I want as-type-in change event triggered. what should i do for a live event in jQuery?
I've used :
jQuery('#element').on('change',function(){
//do the stuff
});
you can use keyup()
event:
$('#someInput').keyup(function() {
// Your code here
});
there is also an input event:
$('#someInput').on('input', function() {
// Your code here
});
as frnhr pointed out, it's better to use input
event because: "input will handle any change - e.g. if you paste something in the field, input will trigger but keyup wont."
You should use keyUp()
$( "#target" ).keyup(function() {
alert( "Handler for .keyup() called." );
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With