Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Text Field Value Change, Bind Function

Tags:

jquery

Is there a way to bind the change event for a text field in jQuery? I.E. whenever the value changes, call some function? I am currently using keyup but that doesn't hit every case, i.e. right click and paste.

Thanks.

like image 669
Justin Avatar asked Nov 14 '11 02:11

Justin


People also ask

How can check input value change or not in jQuery?

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.

How do I set the value of a element in jQuery?

The val() method returns or sets the value attribute of the selected elements. When used to return value: This method returns the value of the value attribute of the FIRST matched element.

Does jQuery Val trigger change event?

When you dynamically set a value in a textfield using jQuery . val(), you have to manually trigger the . change event if you want to add extra code that trigger when the value of the field change.


1 Answers

$("#element").bind("keyup input paste", function() {
    //Do Work Here
});
like image 82
Justin Avatar answered Oct 13 '22 11:10

Justin