In order to get this done, we have to take into account the height of that new message and the height of the previous message. Inside Atom, we're going to go ahead and get that done, by first up adding a selector.
We're going to make a variable called newMessage, and this is going to store the selector for the last list item, the one that was just added before the call to scroll to bottom. I'm going to use jQuery to get this done, but instead of creating a new selector, we can actually build off of our previous one, messages, and we're going to call its children method:
function scrollToBottom () { // Selectors var message = jQuery('#message'); var newMessage = message.children();
This lets you ...