Name
scrollLeft, scrollTop — NN n/a IE 4 DOM n/a
Synopsis
Read/Write
The distance in pixels between the actual left or top edge of the
element’s physical content and the left or top edge of the
visible portion of the content. Setting these properties allows you
to use a script to adjust the scrolling of content within a
scrollable container, such as text in a TEXTAREA
element or an entire document in the browser window or frame. When
the content is not scrolled, both values are zero. Setting the
scrollTop property to 15 scrolls the document
upward by 15 pixels in the window; the scrollLeft
property is unaffected unless explicitly changed. The property values
change as the user adjusts the scrollbars.
Example
document.body.scrollTop = 40
Value
Positive integer or zero.
Default
0
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access