title: JQuery chat application scroll to bottom of div ONLY on new message?
body: <p>I have picked up this AJAX code from multiple tutorials, but the problem is, when the ajax is called, the div ALWAYS scrolls to the bottom. But I want it so that the div ONLY scrolls if there are new messages in the div.</p>
  
  <pre><code>$.ajax({
    url: "msg-handle/get-messages.php",
    cache: false,
    data: { room: $("#room").val() },
    success: function(data) { $('#chat').html(data)
  
  $("#chat").scrollTop($("#chat")[0].scrollHeight);
  
    },
  });
  
  }, 500);
  </code></pre>
  
  <p>Is there a way to achieve this <strong>without</strong> any major ramifications to my code?</p>