jQuery CSS Operation - scrollLeft() Method
Example
Set the horizontal offset of the scrollbar in the <div> element:
$(".btn1").click(function(){ $("div").scrollLeft(100); });
Definition and Usage
The scrollLeft() method returns or sets the horizontal scrollbar position of the matching elements.
The horizontal position of the scrollbar refers to the number of pixels scrolled from the left. When the scrollbar is at the far left, the position is 0.
Returns horizontal scrollbar position
Returns the horizontal scrollbar position of the first matching element.
Syntax
$(selector).scrollLeft()
Set horizontal scrollbar position
Sets the horizontal scrollbar position of all matching elements.
Syntax
$(selector).scrollLeft(position)
Parameters | Description |
---|---|
position | Optional. Specifies the new position in pixels. |