Return the vertical scrollbar position for a <div> element:
The scrollTop() method sets or returns the vertical scrollbar position for the selected elements.
Tip: When the scrollbar is on the top, the position is 0.
When used to return the position:
This method returns the vertical position of the scrollbar for the FIRST matched element.
When used to set the position:
This method sets the vertical position of the scrollbar for ALL matched elements.
Return vertical scrollbar position:
Set vertical scrollbar position:
Parameter | Description |
---|---|
position | Specifies the vertical scrollbar position in pixels |
Set the vertical scrollbar position
How to set the vertical scrollbar position for an element.