jQuery change() method
Example
When Alert text when the field changes:
$("input").change(function(){
alert("The text has been modified");
});
Try it »
Definition and Usage
The change event occurs when the value of an element changes (only for form fields).
The change() method triggers the change event, or specifies a function to run when a change event occurs.
**Note:** When used on a select element, the change event occurs when an option is selected. When used on a text field or text area, the change event occurs when the element loses focus.
Syntax
Trigger the change event of the selected element:
$(
selector
).change()
Try it
Add a function to the change event:
$(
selector
).change(
function
)
Try it
| Parameters | Description |
|---|---|
| function | Optional. Specifies the function to run for the selected element when the change event occurs. |
jQuery event methods