jQuery change () method
Examples
When the <input> field to change the alert text:
$ ( "Input"). Change (function () {
alert ( "text has been modified");
});
alert ( "text has been modified");
});
try it"
Definition and Usage
A change event occurs when the value changes element (only for form fields).
change () method triggers the change event, or when a predetermined function is run when a change event occurs.
Note: When used to select elements, change event occurs when selecting an option.When used in text field or text area, change event occurs when the element loses focus.
grammar
Trigger the selected element change events:
$(selector).change() 尝试一下
Add the function to the change event:
$(selector).change(function) 尝试一下
参数 | 描述 |
---|---|
function | 可选。规定针对被选元素当 change 事件发生时运行的函数。 |