Dynamically Scrolling a Textarea

后端 未结 5 837
伪装坚强ぢ
伪装坚强ぢ 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:19

    For using like textarea in your example give your textarea a name like "id=LiveTextArea"

    Then add buttom of your javascript this (LiveTextArea is the id name):

    LiveTextArea.scrollTop = LiveTextArea.scrollHeight;

    So would look like:

    var textArea = document.getElementById('outputTextResultsArea');

    textArea.scrollTop = textArea.scrollHeight;

    Now the textarea will dynamicly scroll caret/down on any new entry.

提交回复
热议问题