.scrollLeft()Returns: Integer
Description: Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
-
version added: 1.2.6.scrollLeft()
- This method does not accept any arguments.
The horizontal scroll position is the same as the number of pixels that are hidden from view to the left of the scrollable area. If the scroll bar is at the very left, or if the element is not scrollable, this number will be 0
.
Note:.scrollLeft()
, when called directly or animated as a property using .animate()
, will not work if the element it is being applied to is hidden.
Example:
Get the scrollLeft of a paragraph.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
|
Demo:
.scrollLeft( value )Returns: jQuery
Description: Set the current horizontal position of the scroll bar for each of the set of matched elements.
-
version added: 1.2.6.scrollLeft( value )
-
valueType: NumberAn integer indicating the new position to set the scroll bar to.
-
The horizontal scroll position is the same as the number of pixels that are hidden from view above the scrollable area. Setting the scrollLeft
positions the horizontal scroll of each matched element.
Example:
Set the scrollLeft of a div.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
|