Home  >  Article  >  Web Front-end  >  About js monitoring input median value changes in real time (graphic tutorial)

About js monitoring input median value changes in real time (graphic tutorial)

亚连
亚连Original
2018-05-18 14:19:582239browse

The following is the js I compiled for you to monitor the changes in the input median value in real time. Interested students can take a look. aab34cdd5f497851e3d3dc5f70ede385

    ##
    <html>  
        <head>  
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
            <title>RunJS</title>  
        <script id="jquery_183" type="text/javascript" class="library" src="/js/sandbox/jquery/jquery-1.8.3.min.js"></script>  
        </head>  
        <body>  
            <h1 >  
                实时监测input中值的变化  
            </h1>  
            <input type="text" id="username" autoComplete=&#39;off&#39;>  
            <div id="result"></div>  
        </body>  
    </html>
  1. $(function(){  
    $(&#39;#username&#39;).bind(&#39;input propertychange&#39;, function() {  
        $(&#39;#result&#39;).html($(this).val().length + &#39; characters&#39;);  
    });  
    })
oninput, onpropertychange, onchange usage
onchangeTriggering events must meet two conditions:
a) The current object property changes and is triggered by a keyboard or mouse event (Script triggering is invalid)
b) The current object loses focus (onblur);
onpropertychange, as long as the current object properties change, the event will be triggered, but it It is exclusive to IE;
oninput is the non-IE browser version of onpropertychange, which supports browsers such as firefox and opera, but there is one difference. When it is bound to an object, it is not the object. All property changes can trigger events, which only work when the object value changes.
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

What are the ways to encrypt passwords in nodejs

js Detailed explanation on determining whether the client can access the Internet

What are the ways to encrypt passwords in nodejs

The above is the detailed content of About js monitoring input median value changes in real time (graphic tutorial). For more information, please follow other related articles on the PHP Chinese website!

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