Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 18:16:271020browse

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:


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