Dynamically Scrolling a Textarea

后端 未结 5 838
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 08:42

I have a textarea html element on my page that gets reloaded via ajax. The whole textarea is returned each time not just its content, and the content grows over time. Along

5条回答
  •  时光说笑
    2020-11-29 09:14

    As a quick hack you can just do this:

    textArea.scrollTop = 99999;
    

    Another option is to try it in a timer:

    setTimeout(function()
    {
        var textArea = document.getElementById('outputTextResultsArea');
        textArea.scrollTop = textArea.scrollHeight;
    }, 10);
    

提交回复
热议问题