textarea多行文本框自適應高度


<script src="https://cdn.bootcss.com/jquery/1.8.1/jquery.js"></script>
<script>
    $(function(){
        function autoHeight(ele){
            var $this = $(ele);
            $this.css({'height':'20px','overflow-y':'hidden'}).height(ele.scrollHeight);
            if(parseInt($this.height())>60){
                $this.height(60);
            }
        }
        $('.text').on('input propertychange',function(){
            autoHeight(this);
        })
    $('.text').trigger("input");
$('.text').trigger("propertychange");
})
 }) </script>
<textarea name="message"  class="text"></textarea>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM