I'm looking for a (jQuery) Event Handler that is executing a function immediately after a input[type="text"]
value changed. The .change
jQuery event handler is executing the function after the input[type="text"]
looses focus (which may be good for another situation).
keypress
/ up
/ down
only work when the user types something into an input (not when I'm manipulating it dynamically).
Is there any solution for this?
Try oninput : Unlike oninput , the onchange event handler is not necessarily called for each alteration to an element's value. Please Note: You also should not use function keyword as your function name.
The change() is an inbuilt method in jQuery that is used to detect the change in value of input fields. This method works only on the “<input>, <textarea> and <select>” elements. Parameter: It accepts an optional parameter “function”. Return Value: It returns the element with the modification.
The HTML DOM event onfocus is triggered whenever an HTML element it is assigned to receives focus from the user. This event is usually used with <input>, <select> and <a> tags.
One thing that I do in cases like this is to bind the same handler to a bunch of events.
$('input').bind("change blur keyup mouseup", function() {
$(this).css("color", "red"); // or whatever you want to happen
});
See http://api.jquery.com/bind/
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