# jQuery scrollTop()

The jQuery scrollTop method is used to set or return the vertical scrollbar position of selected element. It provides the current vertical position of the selected element, when it is used to return the position, and it sets the vertical scrollbar position of the selected element, when it is used to set the position.

Syntax
When used to return the vertical scrollbar position:

$(selector).scrollTop()  When used to set the vertical scrollbar position: $(selector).scrollTop(position)


Position:

• This is a mandatory parameter which is used to specify the vertical scrollbar position to be set.
• This parameter accepts values in pixels.
• The top position of the scrollbar is on the top, is termed as position 0.

## Example 1

Below is the example to return the vertical scrollbar position using scrollTop() method.