Q:

Scroll Bar should go to bottoop m whenever a new item is entered in the window at the bottom

I have a control like chat control in my project & the scroll bar should be set to bottom whenever a new message is entered at the bottom. Right now, the message is getting added but the position of scroll bar remains same. I have tried all solns given on StackOverflow like 
set ScrollTop to 9999999. cannot set it to the width of the container, because it is getting increased dynamically.
Please help.

A:

You should use html prop scrollHeight and set the container scrollTop for it:
insertMessage = function(message) {
  $('#chat ul').append('<li>' + message + '</li>');
  var height = document.getElementById('chat-dialog').scrollHeight;
  $('#chat').scrollTop(height);
};

