How do I get the scroll position of a document?

前端 未结 9 1737
面向向阳花
面向向阳花 2020-12-12 20:53

How to get the scroll position value of a document?

9条回答
  •  [愿得一人]
    2020-12-12 21:39

    You can try this for example, this code put the scrollbar at the bottom for all DIV tags

    Remember: jQuery can accept a function instead the value as argument. "this" is the object treated by jQuery, the function returns the scrollHeight property of the current DIV "this" and do it for all DIV in the document.

    $("div").scrollTop(function(){return this.scrollHeight})
    

提交回复
热议问题