jQuery - 在垂直可滚动文档中查找窗口顶部的 y 位置

标签 jquery offset

我有一个非常高并且垂直滚动的文档。我想在某个时间检测可见区域相对于完整文档的关系。

因此,如果 $('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/

相关文章:

javascript - 在随机位置的侧div中生成数字而不重叠

javascript - JQuery 验证自定义错误消息未显示

excel - 偏移量不适用于 Google 表格中的导入范围。有什么解决方法吗?

apache-kafka - 为什么无法将 Kafka 偏移量设置到主题的开头?

jquery - 原型(prototype)等效于 JQuery 的 offset()

jquery - 在 Jquery 中加载页面时展开第一个菜单选项

javascript - jquery 复选框组选中/取消选中只工作一次

PHP: undefined offset

C++ 读取内存地址/指针和偏移量

jquery - 使用 jQuery UI .sortable 的序列化方法获取排序元素的 html 作为值