Example
Get the horizontal position of the scrollbar in a div element:
$("button").click(function(){ alert($("div").scrollLeft()+"
px");
}); |
Try it yourself »
|
Definition and Usage
The scrollLeft() method sets or returns the horizontal position of the scrollbar
for the selected elements.
The horizontal position of the scrollbar is the number of pixels scrolled from its left
side. When the scrollbar is on the far left side, the position is 0.
Return Horizontal Scrollbar Position
Returns the horizontal position of the scrollbar for the FIRST matched element.
Syntax
Set Horizontal Scrollbar Position
Sets the horizontal position of the scrollbar for all matched elements.
Syntax
Parameter |
Description |
position |
Optional. Specifies the new position in pixels |