你的位置:首页 > 软件开发 > Java > textarea 高度自适应

textarea 高度自适应

发布时间:2015-03-10 17:02:41
1 jQuery.fn.extend({ 2 autoHeight: function(){ 3 return this.each(function(){ 4 var $this = jQuery(this); 5 ...
 1 jQuery.fn.extend({ 2       autoHeight: function(){ 3         return this.each(function(){ 4           var $this = jQuery(this); 5           if( !$this.attr('_initAdjustHeight') ){ 6             $this.attr('_initAdjustHeight', $this.outerHeight()); 7           } 8           _adjustH(this).on('input', function(){ 9             _adjustH(this);10           });11         });12         /**13          * 重置高度 14          * @param {Object} elem15         */16         function _adjustH(elem){17           var $obj = jQuery(elem);18           return $obj.css({height: $obj.attr('_initAdjustHeight'), 'overflow-y': 'hidden'})19               .height( elem.scrollHeight );20         }21       }22     });23     // 使用24     $(function(){25       $('textarea').autoHeight();26     });

原标题:textarea 高度自适应

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录