首页 > 其他 > 详细

textarea多行文本框自适应高度

时间:2018-01-10 10:29:02      阅读:345      评论:0      收藏:0      [点我收藏+]
<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>

 

textarea多行文本框自适应高度

原文:https://www.cnblogs.com/jkingdom/p/8243984.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!