我有一个非常高并且垂直滚动的文档。我想在某个时间检测可见区域相对于完整文档的关系。
因此,如果 $('body').height()
为 6000,并且当我的函数触发时,它们会滚动 2/3,我希望能够取回数量 4000
。
我知道这很简单,但我就是想不通。
最佳答案
$('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.
来自 .scrollTop()
关于jQuery - 在垂直可滚动文档中查找窗口顶部的 y 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10964673/