Home >Web Front-end >JS Tutorial >Introduction to triggering events when input tag content changes_javascript skills

Introduction to triggering events when input tag content changes_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:43:551629browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn