jQuery scrollTop() does not work in scrolling DIV on mobile browsers, alternatives?

前端 未结 13 1020
傲寒
傲寒 2020-12-08 19:52

I am trying to scroll to a specific location in a scrolling DIV. Right now I am using a pixel offset with the jQuery scrollTop() function which works great on desktop brows

13条回答
  •  盖世英雄少女心
    2020-12-08 20:12

    Try using jQuery's .animate method:

    $('.div').animate({ scrollTo: x; });
    

    Where x is equal to the position of the div you want to scroll to the top of.

提交回复
热议问题