Most of the solutions provided in this site use some variants of this code to scroll down to the bottom of a div
$("ol.overflow-element").animate({
scrollTop: $("ol.overflow-element li:last-child").position().top
}, 1000);
I have this in the css
.overflow-element {
overflow-y: scroll;
height: 300px;
padding: 10px;
}
The problem I am having is that it is very inconsistent.
Sometimes it correctly moves to the bottom.
But other times it scrolls somewhere near the top or middle. This happens consistently when the div is already scrolled to the bottom.
Any reason why this is the case? Any alternative, correct impelemntation?