"change" event
The change event is fired for <input>
, <select>
, and <textarea>
elements when an alteration to the element's value is committed (entered) by the user. Unlike the input event, the change event is not necessarily fired for each alteration to an element's value.
"change" event:value 被確認之後 (如:按 enter) 才會觸發的事件。
"input" event:只要 value 發生改變就會觸發的事件。
when "change" event fires
元件 | type | event |
<input> | radio, checkbox | click |
<input> | date, file | select |
<select> | select | |
<input> | text | element loses focus after its value was changed, but not committed |
<textarea> | (same above) |
code example
Last updated