scrollLeft() method in jQuery

scrollLeft() in jQuery

This method is used to Get or Set the current horizontal position of the scroll bar of the first specified element.

The value returned by this method specifies the number of pixels that are hidden to the left of the scrollable area.

If the scroll bar is at the left end, or if the element is not scrollable or disabled, the returned value will be 0.

Syntax

$(selector).scrollLeft([value])

  • value - It denotes a number indicating the new position of the scroll bar.

Example 1 - get

Try Yourself

Example 2 - Scroll to right by the specified value

Try Yourself