html實時監聽input變化

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body id="lia-body">
    <div class="lia-content">
        <div class="inputwrapper">
            <label><span></span><input type="text" name="fullname"></label>
            <div class="result"></div>
        </div>
    </div>
    <script src="http://apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
        $(function(){
            var $inputwrapper = $('#lia-body .lia-content .inputwrapper');
            $inputwrapper.find('input').on('input propertychange',function(){
                var result = $(this).val();
                console.log(result);
                $inputwrapper.find('.result').html(result);
            });
        })
    </script>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章