_javascript Techniques of JS textinput text event in DOM3

Source: Internet
Author: User
Unlike KeyPress, the event is triggered only when the user enters a visual character, and the Keypres event triggers (such as capslock,backspace) by pressing the key.
You can see that the textinput is mainly about characters, and you can get the input characters from the event object's Data property.
Example
<! DOCTYPE html> <ptml> <pead> <title>dom3 event textinput</title> </pead> <body> <input id= "IPT" type= "text"/> <script type= "Text/javascript" > Function addevent (EL,TYPE,FN) {if (El.addev Entlistener) {El.addeventlistener (type, FN, false); }else{el.attachevent (' on ' + type, fn); } var IPT = document.getElementById (' IPT '); Addevent (IPT, ' TextInput ', function (e) {e = e | | window.event; Console.log (E.data); }); </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

At present only Ie9,chrome,safari support.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.