jQuery Event - change() Method
Example
Change the color when the input field changes:
$(".field").change(function() { $(this).css("background-color","#FFFFCC"); });
Definition and Usage
A change event occurs when the value of an element changes.
This event is applicable only to text fields, as well as textarea and select elements.
The change() function triggers the change event or specifies the function to be executed when the change event occurs.
Note:When used with select elements, the change event occurs when an option is selected. When used with text fields or text areas, the event occurs when the element loses focus.
Trigger change event
Trigger the change event of the selected element.
Syntax
$().change()
Bind the function to the change event
Specifies the function to be executed when a change event occurs on the selected element.
Syntax
$().change(function)
Parameters | Description |
---|---|
function | Optional. Specifies the function to be executed when a change event occurs. |