Example 1 — Get the Vertical Offset
Official style: read scrollTop from the first paragraph.
var p = $("p").first();
$("p").last().text("scrollTop:" + p.scrollTop());
// typically "scrollTop:0" for a normal paragraph How It Works
- Select.
$("p").first()is the element to measure. - Getter.
.scrollTop()returns a number (no args). - Typical result. A normal paragraph is not scrolled →
0.

