jQuery Scroll to bottom of Div even after it updates?

后端 未结 1 885
抹茶落季
抹茶落季 2021-01-04 03:18

So I have a page with a chat-like div that fills up with text. It has a fixed height and width (defined by css).

I need it to scroll to bottom upon every update, her

相关标签:
1条回答
  • 2021-01-04 03:23

    Have you tried with .scrollHeight:

    $("#div1").animate({ scrollTop: $("#div1")[0].scrollHeight}, 1000);
    

    scollHeight documentation at MDN

    0 讨论(0)
提交回复
热议问题