Reputation: 87
I have an inner div that contains a list with the most recent list item being at the bottom. The div is part of a larger page. Essentially i want the div to default to the end of the list item and the user will then scroll upwards within the div to see the older content. I do not want the page to be scrolled to the bottom of the div which would occur if i used the following function
//Slide chat down to bottom
$("#div").scrollTop(function(){
return $(this).height();
});
The outer div would be the page at large. therefore the user would need to scroll down to the inner div and then see the last list item. If they want they can then use the inner scroll bar to look up older items
thanks
Upvotes: 1
Views: 70
Reputation: 47667
You can do that in plain JavaScript:
var inner = document.querySelector('.inner');
inner.scrollTop = inner.scrollHeight;
Upvotes: 1