I have a div element and a simple style sheet for it :
CSS:
.container{
width:200px;
max-height:200px;
border:1px solid red;
overflow-y:scroll;
}
HTML:
<div class="container">
</div>
And i have a button for add contents to the div, as you know my div
's height grows then has an scroll bar.
When i add new contents to the container, i want to show the last added item.
I try to use scrollTop()
jQuery function with infinite value but it didn't work.
Any Idea?
Edit : Because of using max-height, the maximum value of height property is 200. So i can't use this approach :
$(".container").scrollTop($(".container").heigth());
Now, i can do it like this:
$(".container").scrollTop(10000);
And it's working, but i think it isn't good idea!
Update
Thanks to Nicole Van for the simple and great approach! I change my fiddle with her solution : The Updated Fiddle