//自适应
$('textarea').each(function () {
this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
}).on('input', function () {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
转载自:https://blog.csdn.net/qq_35607510/article/details/74331305
本文介绍了一种使用jQuery实现的自适应文本区域高度的方法,通过监听输入事件动态调整文本区域的高度,确保其能够自动扩展以适应输入的内容长度,避免滚动条出现。

886

被折叠的 条评论
为什么被折叠?



