2014-02-15 67 views
0

我使用下面的代码来提醒滚动到页面底部的消息。 当我滚动到页面顶部时,它会发出警报。滚动到底部的作品,当我滚动到顶部

出了什么问题?

$(window).scroll(function(){ 

     if($(window).scrollTop() == $(document).height()-$(window).height()){ 

      alert("BOTTOM"); 
       } 
}); 
+1

这似乎工作...你能提供一个形象呢?采取[看...](http://jsfiddle.net/DXSfw/) – Cilan

+0

我只是试了一下,它适用于我... – Toothbrush

+0

现在它的工作!谢谢。 <!DOCTYPE html>在文件 – user3260392

回答

0

尝试

$("html, body").animate({ scrollTop: $(document).height() }, 1000); 
+0

中缺失解释为什么这是通过编辑答案。 –