JQuery – find y-position of top of window in vertically scrollable document

jqueryoffset

I have a document that is very tall and gets scrolled vertically. I would like at a certain time to detect what the visible area is in relation to the full document.

So if $('body').height() is 6000 and when my function triggers they are scrolled 2/3 of the way through, I would like to be able to get back the number 4000.

I know this is simple, I just cant figure it out.

Best Answer

$('body').scrollTop()

The vertical 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 top, or if the element is not scrollable, this number will be 0.

from .scrollTop()