My problem is a bit off the cuff here, so I'll try to explain this best I can.
I have a text area, having css of #object{overflow:hidden;resize:none;}
. I am trying to prevent it from spawning scroll bar while also resizing itself. This textarea is synced with an external script's console meaning it updates. By default however, it will stay at the top unless you highlight text, dragging off to the bottom of the element. This would be the only way to scroll down other than with arrow keys, naturally.
Programmatically, is there any way to keep the text area down to the bottom upon updating? It would be nice to have it auto-scroll to accommodate its use case.
Using Javascript
Using Jquery
You can do it by javascript. Set the
scrollTop
property of text area withscrollHeight
property like below:Generic JQuery Plugin
Here a generic jquery plugin for scrollBottom of any element:
usage:
By using jQuery, you can find out when the content of the
textarea
changes using:And scroll to the bottom using:
Scroll code taken from jquerybyexample.blogspot.com.
Call this function every time when the contents of the textarea are changed. If you cannot edit the external influence, periodically activate this function using setInterval.