function setHeight(element) {
$(element).css({'height':'auto','overflow-y':'hidden'}).height(element.scrollHeight);
}
$('textarea').each(function () {
setHeight(this);
}).on('input', function () {
setHeight(this);
});
作者:WTIFS
链接:https://www.zhihu.com/question/32295778/answer/119649853
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。