Home > Web Front-end > JS Tutorial > Use onpropertychange and oninput events to solve the shortcomings of onchange events in javascript development_jquery

Use onpropertychange and oninput events to solve the shortcomings of onchange events in javascript development_jquery

WBOY
Release: 2016-05-16 18:16:27
Original
1060 people have browsed it

onchange has an obvious shortcoming when used in a text box input box. The event will not be triggered with the input of text, but will be triggered when the text box loses focus (onblur). That is, there is no immediacy. !

In IE, you can use onpropertychange to replace the onchange event. When there is any change in the text box, can trigger the event immediately.

This way the problem is solved.

What about other browsers? onpropertychange is a patent of IE. Next is the oninput event.

But there is something strange about oninput. You must use addEventListener to bind events. Otherwise it will be invalid.

Okay, the following is a demonstration example, no problem with mainstream browsers:


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template