Search results
The scrollTop property sets or returns the number of pixels an element's content is scrolled vertically. See Also: The scrollLeft Property. The CSS overflow Property. The onscroll Event. Syntax. Return the scrollTop property: element.scrollTop. Set the scrollTop property: element.scrollTop = pixels. Property Values. Return Value. More Examples.
- Try It Yourself
The W3Schools online code editor allows you to edit code and...
- jQuery scrollTop() Method
The scrollTop () method sets or returns the vertical...
- Try It Yourself
11 wrz 2024 · The Element.scrollTop property gets or sets the number of pixels by which an element's content is scrolled from its top edge. This value is subpixel precise in modern browsers, meaning that it isn't necessarily a whole number.
18 sty 2018 · You can use element.scrollTop and element.scrollLeft to get the vertical and horizontal offset, respectively, that has been scrolled. element can be document.body if you care about the whole page. You can compare it to element.offsetHeight and element.offsetWidth (again, element may be the body) if you need percentages.
The scrollTop () method sets or returns the vertical scrollbar position for the selected elements. Tip: When the scrollbar is on the top, the position is 0. This method returns the vertical position of the scrollbar for the FIRST matched element.
.scrollTop() Returns: Number Description: Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.
9 cze 2023 · The DOM scrollTop property is used to return or set the number of pixels an element is scrolled vertically. If the element’s content doesn’t generate a scroll bar, then its scrollTop value is 0. Syntax: It returns the scrollTop property. element.scrollTop.
The Element.scrollTop property gets or sets the number of pixels that an element's content is scrolled vertically. An element's scrollTop value is a measurement of the distance from the element's top to its topmost visible content.