JS Real-time monitoring input value change

Source: Internet
Author: User

JS Real-time monitoring input value changeCategory: Javascript2014-05-11 11:13 849 people read comments (0) favorite reports

[HTML]View Plaincopyprint?
  1. <! DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv= "content-type" content= "text/html; Charset=utf-8 ">
  5. <title>runjs</title>
  6. <script id="jquery_183" type="Text/javascript" class= "Library" src="/js /sandbox/jquery/jquery-1.8.3.min.js "></script>
  7. </head>
  8. <body>
  9. <H1 >
  10. Real-time monitoring of changes in input values
  11. </H1>
  12. <input type="text" id="username" autocomplete=' off '>
  13. <div id="result"></div>
  14. </Body>
  15. </html>

[JavaScript]View Plaincopyprint?
    1. $ (function () {
    2. $ (' #username '). Bind (' input propertychange ', function () {
    3. $ (' #result '). HTML ($ (this). Val (). length + ' characters ');
    4. });
    5. })

Similar to the use of the ' can input xxx characters ' oninput,onpropertychange,onchange in the implementation of Weibo onchangeThe triggering event must meet two conditions: a) The current object property is changed and is fired by a keyboard or mouse event (Invalid script trigger) b) The current object loses focus (onblur); Onpropertychange, the event is triggered whenever the current object property is changed, but it is exclusive to IE; OninputOnpropertychange is a non-IE browser version that supports browsers such as Firefox and Opera, but a little different when it's bound to an object, not all property changes in that object can trigger events, it only works if the object's value changes.

JS Real-time monitoring input value change

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.