jQuery代码可自动扩展表单上的textarea输入字段。 该插件利用scrollTop DOM属性获取文本的真实高度,然后将其直接(或通过动画)应用于文本区域。
插件使用
$('textarea#comment').autoResize({
// On resize:
onResize : function() {
$(this).css({opacity:0.8});
},
// After resize:
animateCallback : function() {
$(this).css({opacity:1});
},
// Quite slow animation:
animateDuration : 300,
// More extra space:
extraSpace : 40
});
From: https://www.sitepoint.com/jquery-auto-expand-textarea/