固定高度的textarea中动态塞值,让内容自动滚动到底部
网友回复
微盟:
<html>
<body>
<textarea rows="10" cols="20" id="my">
</textarea>
<button onClick="test()">test</button>
<script>
var i = 1;
function test()
{
var obj = document.getElementById("my");
obj.value += i + "\n";
i++;
obj.scrollTop = obj.scrollHeight; // good
}
</script>
</body>
</html>
showms:
textarea有一个属性是cursor,试试设置成最后一位
https://developers.weixin.qq.com/miniprogram/dev/component/textarea.html