Easy Tutorial
❮ Ajax Ajaxsuccess Css Width ❯

jQuery scrollLeft() Method

jQuery HTML/CSS Methods

Example

Return the horizontal scroll bar position of a <div> element:

$("button").click(function(){
    alert($("div").scrollLeft());
});

Definition and Usage

The scrollLeft() method sets or returns the horizontal scroll bar position for the selected elements.

Tip: When the scroll bar is at the far left side, the position is 0.

When used to return the position: This method returns the horizontal position of the scroll bar for the first element in the set of matched elements.

When used to set the position: This method sets the horizontal position of the scroll bar for all matched elements.


Syntax

Return the horizontal scroll bar position:

Set the horizontal scroll bar position:

Parameter Description
position Specifies the horizontal scroll bar position in pixels.

More Examples

Set the Horizontal Scroll Bar Position


jQuery HTML/CSS Methods

❮ Ajax Ajaxsuccess Css Width ❯