1
I have a div that updates every 4 seconds and I use the overflow on it, I need the scrollbar to always be aligned on the last line. any suggestions?
1
I have a div that updates every 4 seconds and I use the overflow on it, I need the scrollbar to always be aligned on the last line. any suggestions?
2
What you need is to give the scroll the height of the div, after updating the content. Something like:
var height = el.scrollHeight;
el.scrollTop = height;
Note: In Firefox the height of the div that will expand must be closed, for the browser to pass this div to scroll view mode. Like in the CSS of the example I put.
Browser other questions tagged jquery css
You are not signed in. Login or sign up in order to post.
in this example the scroll bar continues always above, however I needed it to accompany the low items being created
– Arsom Nolasco
@Arsomnolasco to me the bar is always down... which browser you are using?
– Sergio
mozzila firefox, and really on Crhome is down, is there any " cat to work on ff too? I even found that it worked but only at the beginning it stays, then if another line is added remains still $(".messages"). Animate({ scrollTop: $(Document).height() }, "fast"); Return false;
– Arsom Nolasco
@Interesting arsomnolasco. I think I know what it is, give me a few minutes.
– Sergio
@Arsomnolasco has a look here: https://jsfiddle.net/xtxj6orp/1/ you have to select the maximum height of the expanding element. To switch it to mode scroll when that time is reached.
– Sergio
Perfect, it worked right if you can edit your answer by inserting this detail into the mozila also thank you for helping others with the same doubts
– Arsom Nolasco
@Arsomnolasco done, thank you.
– Sergio