Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery scrollLeft() method

jQuery scrollLeft() method

jQuery HTML/CSS methods jQuery HTML/CSS methods

Example

Return

The horizontal scrollbar position of an element:

$

(

"

button

"

)

.

click

(

function

(

)

{

alert

(

$

(

"

div

"

)

.

scrollLeft

(

)

)

;

}

)

;

Try it »


Definition and Usage

The scrollLeft() method sets or returns the horizontal scrollbar position of the selected elements.

**Tip:** When the scrollbar is at the far left, the position is 0.

**When used to return the position:
**This method returns the horizontal scrollbar position of the first matched element.

**When used to set the position:
**This method sets the horizontal scrollbar position of all matched elements.


Syntax

Return the horizontal scrollbar position:

$(

selector

).scrollLeft()

Set the horizontal scrollbar position:

$(

selector

).scrollLeft(

position

)

Parameters Description
position Specifies the horizontal scrollbar position in pixels.

More examples

Set the horizontal scrollbar position
How to set the horizontal scrollbar position of an element.


jQuery HTML/CSS methods jQuery HTML/CSS methods