Change event
The change event for <input>, <select>, and <textarea> elements fires when the user modifies the element's value. Unlike the input event, the change event does not necessarily fire on every alteration to an element's value.
Overview
The change event for <input>, <select>, and <textarea> elements fires when the user modifies the element's value. Unlike the input event, the change event does not necessarily fire on every alteration to an element's value.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 1 | 12 | 1 | 3 | 18 | 2 | |
Syntax
<select onchange="console.log(this.value)">
<option value="a">A</option>
<option value="b">B</option>
</select>
<script>
document.querySelector('select').addEventListener('change', e => {
console.log('変更:', e.target.value);
});
</script> Live demo
Change and input. Difference
Change is value. certain time, input is ki-input. to emitdifference.
Use cases
Using Change event
The change event for <input>, <select>, and <textarea> elements fires when the user modifies the element's value. Unlike the input event, the change event does not necessarily fire on every alteration to an element's value.
Cautions
- May not be supported in older browsers.
Accessibility
- Verify how this element is announced by screen readers.
Related links
Powered by web-features