How do I get the scroll position of a document?

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

How to get the scroll position value of a document?

9条回答
  •  旧时难觅i
    2020-12-12 21:31

    Here's how to get the scrollHeight of an element obtained using a jQuery selector:

    $(selector)[0].scrollHeight
    

    If selector is the id of the element (e.g. elemId), it is guaranteed that the 0-indexed item of the array will be the element you wish to select, and scrollHeight will be correct.

提交回复
热议问题