I'm simply trying to do something once the scroll position of the page reaches a certain height. However scrollTop() is returning 0 or null no matter how far down I scroll. This is the help function I'm using to check the scrollTop() value:

$('body').click(function(){
    var scrollPost = $(document).scrollTop();
    alert(scrollPost);
});

我试着把scrollTop()$('body')$('html'),当然还有$(window)连接起来,但没有任何变化.

有什么主意吗?

推荐答案

For some reason, removing 'height: 100%' from my html and body tags fixed this issue.

我希望这对其他人有帮助!

Jquery相关问答推荐

jQueryUI 模态对话框不显示关闭按钮 (x)

无法使用 HTML 设置未定义的 jQuery UI 自动完成的属性_renderItem

如果您的 Select 器对象无效,为什么 jQuery 不会炸弹?

如何在 jquery 中从这个日期减go 一周?

javascript中的描述关键字

使用 JavaScript 和 jQuery,跨浏览器处理按键事件 (F1-F12)

jQuery切换文本?

按值对 Html Select 的选项进行排序的最有效方法是什么,同时保留当前选定的项目?

如何更改 dropzone.js 中的默认文本?

jQuery 插件:添加回调功能

带有 jquery 的 jsonp

测试两个元素是否相同

使用 JavaScript 获取用户代理

使用 JQuery 激活 bootstrap 选项卡

AngularJS:使用 jQuery 更改时,ng-model 绑定不更新

jQuery select2 获取 Select 标签的值?

组织 jQuery/JavaScript 代码的最佳方式 (2013)

如何判断值是否为 JSON 对象?

IE 中带有 jQ​​uery ajax 调用的无传输错误

Drop 事件未在 chrome 中触发