$(document).scrollTop()始终返回0 [英] $(document).scrollTop() always returns 0
本文介绍了$(document).scrollTop()始终返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一旦页面的滚动位置达到一定高度,我就会尝试做某事。但是 scrollTop()
返回0或 null
无论我滚动多远。这是我用来检查 scrollTop()
值的帮助函数:
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')
当然还有 $ (窗口)
,但没有任何变化。
I've tried attaching scrollTop()
to $('body')
, $('html')
and of course $(window)
, but nothing changes.
任何想法?
推荐答案
出于某种原因,删除'身高:100%来自我的html和body标签解决了这个问题。
For some reason, removing 'height: 100%' from my html and body tags fixed this issue.
我希望这可以帮助别人!
I hope this helps someone else!
这篇关于$(document).scrollTop()始终返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文