Description
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.
v1.2.6
This method has the form:
.scrollLeft()
Return Value
This form returns an Integer object.
Set Horizontal Scrollbar Position
Sets the horizontal position of the scrollbar for all matched elements.
v1.2.6
This method has the alternate form:
.scrollLeft(position)
Parameter | Description |
---|---|
position | (optional) Specifies the new position in pixels |
Return Value
This form returns a jQuery object.
Examples
Set the height of all p elements:
$("button").click(function(){
alert($("div").scrollLeft()+"px");
});