jquery - keep window from changing scroll position while prepending items to a list?

前端 未结 6 922
误落风尘
误落风尘 2020-11-29 23:10

I have a page that displays messages and I want it to work just like Facebook, but without the lazy loader. Messages are displayed in chronological order, most recent last.<

6条回答
  •  有刺的猬
    2020-11-29 23:44

    Here's a simple trick that worked for me:

    // divWithTheScroll.prependElement...
    divWithTheScroll.scrollTop += newlyPrependedElement.scrollHeight;
    

提交回复
热议问题