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