返回值:IntegerscrollLeft()
Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
-
1.2.6 新增scrollLeft()
The horizontal scroll position is the same as the number of pixels that are hidden from view above the scrollable area. If
the scroll bar is at the very left, or if the element is not scrollable, this number will be 0
.
示例:
Get the scrollLeft of a paragraph.
<!DOCTYPE html>
<html>
<head>
<style>
p { margin:10px;padding:5px;border:2px solid #666; }
</style>
<script src="jquery.min.js"></script>
</head>
<body>
<p>Hello</p><p></p>
<script>
var p = $("p:first");
$("p:last").text( "scrollLeft:" + p.scrollLeft() );
</script>
</body>
</html>