$(document).ready(function () {
$('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';
});
})
代码来源于:http://www.softwhy.com/article-9626-1.html
注:
1.“蚂蚁部落(http://www.softwhy.com/qiduan/)”网站有很多关于前端的教程;
2.https://blog.csdn.net/cindy647/article/details/87886344此链接有关于输入框input、textarea的零碎知识点;
大家可以前往查阅哦~
网友评论