var element = document.getElementById(comm);
element.style.height = element.scrollHeight + "px";
};```
``<textarea id="comm" ng-model="" ng-keydown="updateEditor(comm)"></textarea>
``
这是绑定事件触发,改变textarea的高度;
也可以通过定时器去更新textarea的高度;
<textarea id="textarea" ng-model="img.name" placeholder="请输入文字备注" rows=1 cols=40 style='overflow:scroll;overflow-y:hidden;overflow-x:hidden'
onfocus="window.activeobj=this;this.clock=setInterval(function(){activeobj.style.height=activeobj.scrollHeight+'px';},200);" onblur="clearInterval(this.clock);"></textarea>```
网友评论