溢出:滚动;jquery在停止工作后一直滚动到某个时刻

overflow: scroll; jquery keeps scrolling until some point, after it stops working

本文关键字:滚动 一直 时刻 停止工作 jquery 溢出      更新时间:2024-04-18

只要继续追加,您就会看到最新的聊天消息出现,但过了一段时间后,它就会自动停止向下滚动。我该怎么解决这个问题?谢谢

http://jsfiddle.net/VMcsU/

$("#button1").click(function(){
    $("<div>").html("text").appendTo("#chat1");
    $('#chat1').scrollTop($('#chat1').height())
});

您需要scrollHeight

DEMO

$("#button1").click(function(){
    $("<div>").html("text").appendTo("#chat1");
    $('#chat1').scrollTop($('#chat1')[0].scrollHeight)
});