How to keep the scroll bar of a div always down?

1

I have a div that updates every 4 seconds and I use the overflow in it, I need the scroll bar always to be aligned on the last line. Any suggestions?

    
asked by anonymous 08.02.2016 / 22:32

1 answer

2

What you need is to give the scroll height of the div, after updating the content. Something like:

var height = el.scrollHeight;
el.scrollTop = height;

Example: link

In Firefox the height of the div that is going to expand must be set, for the browser to pass this div to scroll view mode . Like in the example CSS I put.

More reading:

08.02.2016 / 22:43