menu

jQuery scrollTop Method


jQuery .scrollTop Method : is used to get or set the vertical scrollbar position of the selected element.


jQuery scrollTop Method Syntax 1 – Get The Position

Syntax for get position of scrollbar from top –

jQuery scrollTop() Method Example 1

Below example shows the position of the scrollbar from the top-

Try it »

jQuery scrollTop Method Syntax 2 – Set The Position

Syntax to set position of the scrollbar from top –

position(px): Pixel position to be scrolled.

jQuery scrollTop() Method Example 2

Here is an example which will set position of scrollbar from top –

Try it »

The above example will produce output something like this –

jQuery scrollTop Method Example