Home > Article > Web Front-end > Introduction to triggering events when input tag content changes_javascript skills
1. The difference between onchange event and onpropertychange event:
The onchange event is triggered when the content changes (the two contents may be equal) and the focus is lost; the onpropertychange event is triggered in real time, and will be triggered every time a character is added or deleted. This event will also be triggered by js changes, but this event It is exclusive to IE.
2. The difference between oninput event and onpropertychange event:
The oninput event is an event supported by most browsers except IE. It is triggered in real time when the value changes, but it will not be triggered when the value is changed through js; the onpropertychange event is triggered by any property change, but oninput is only triggered when the value is changed. Triggered when changed, oninput must be registered through addEventListener(), onpropertychange registration method is the same as general events.
3. When oninput and onpropertychange fail:
oninput event:
(1) When the value is changed in the script, it will not be triggered;
(2) When selecting from the browser’s automatic drop-down prompt, it will not be triggered;
onpropertychange event:
When input is set to disable=true, it will not be triggered.