Ror*_*ley 7 jquery jquery-mobile
使用以下代码,我试图找到用户滚动到页面底部的时间.在JQuery mobile中.
$(window).scroll(function(){
if($(window).scrollTop() == $(document).height() - $(window).height()){
alert("The Bottom");
}
});
Run Code Online (Sandbox Code Playgroud)
现在我只是希望它输出它们已达到底部.
我的问题是,当网站加载时,它将输出此消息.当我滚动到底部时,它将输出警报.
有没有办法阻止它在页面加载时执行它并且仅在用户物理滚动页面时执行此操作?
谢谢
是因为您的内容比您的网页短吗?这意味着当它加载时,你已经在底部了.我试图在这里复制你的问题http://jsfiddle.net/qESXR/2/ 它的行为就像你想要的那样.但是,如果我缩短内容并在我的机器上本地运行,我会得到相同的结果.
如果是这样,您可以使用这些来检查页面的高度与html的高度
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
Run Code Online (Sandbox Code Playgroud)
像这样:
$(window).scroll(function(){
if($(document).height() > $(window).height())
{
if($(window).scrollTop() == $(document).height() - $(window).height()){
alert("The Bottom");
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13272 次 |
| 最近记录: |