实时监测input中值的变化 --- bind()方法

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <script id="jquery_183" type="text/javascript" class="library" src="jquery-1.7.2.min.js"></script>
        <script>
            $(function(){

                $('#username').bind('input propertychange', function() {
                    $('#result').html($(this).val().length + ' characters');
                });
            })
        </script>
    </head>
    <body>
        <h1 >
            实时监测input中值的变化
        </h1>
        <input type="text" id="username" autoComplete='off'>
        <div id="result"></div>
    </body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_37580235/article/details/80734984