Home > Web Front-end > H5 Tutorial > How to use input events to monitor mobile input_html5 tutorial tips

How to use input events to monitor mobile input_html5 tutorial tips

WBOY
Release: 2016-05-16 15:37:07
Original
3126 people have browsed it

I encountered a new requirement today. The manager requested that the comment function need to limit the number of characters, just like Weibo, which limits the maximum input of 150 characters. Here, users need to be reminded in real time how many more characters they can enter.

At the beginning, the idea was to listen to the keyup event and then count the number of words entered by the user, but some keys (such as the delete key) will not trigger the event.

Later I checked that HTML5 has added a new input event. This event is similar to the change event, but the change event is triggered when the element loses focus, and the input event is triggered when the element value changes. Trigger

At present, except for IE89, other browsers support it well, and you can use it on the mobile terminal with confidence

The above article on how to use input events to monitor mobile terminal input is all the content shared by the editor. I hope it can give you a reference, and I hope you will support Script Home.

Original address: http://www.cnblogs.com/wodertian/p/5391113.html

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