html:
<textarea type="text" class="mui-input-clear bz_ipt" autoHeight="true"
placeholder="请输入信息"></textarea>
js:
$(function () {
$.fn.autoHeight =function () {
function autoHeight(elem) {
elem.style.height ='auto';
elem.scrollTop =0; //防抖动
elem.style.height = elem.scrollHeight +'px';
}
this.each(function () {
autoHeight(this);
$(this).on('keyup', function () {
autoHeight(this);
});
});
}
$('textarea[autoHeight]').autoHeight();
})
网友评论