weixin_33743248 2019-02-25 09:55 采纳率: 0%
浏览 21

AJAX聊天滚动条向下

The scroll bar doesn't go down on the Chat Page, so what I need to do is I want it to go away when people send messages between themselves but the scrollbar doesn't scroll down when the other person sends the message.

<div class="messages" id="messages" style="overflow:auto">
  <div class="message" id="message">Yükleniyor...</div>
</div>
chat.fetchMessages = function() {
  $.ajax({
    url: 'chat.asp',
    type: 'post',
    data: {
      method: 'fetch'
    },
    success: function(data) {
      $('#messages').html(data);
      $("#messages")[0].scrollHeight - $("#messages").scrollTop() == $("#messages").outerHeight()
    }
  });
}
.messages {
  border: 1px solid #red;
  height: 450px;
  overflow-y: auto;
}
  • 写回答

0条回答 默认 最新

    报告相同问题?