How can I scroll programmatically a div with its own scrollbars?

后端 未结 5 1605
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-05 17:12

I have a HTML page with an internal DIV used for content. The internal DIV has its own scrollbars. I would like to automatically scroll to a certain position in the DIV.

5条回答
  •  独厮守ぢ
    2020-12-05 17:50

    The div has a scrollTop property that you can set (and its pal, scrollLeft).

    • jsFiddle Demo

    • scrollTop on MDN

    • scrollLeft on MDN

提交回复
热议问题