如何获得最大文档滚动值 [英] How to get maximum document scrolltop value

查看:116
本文介绍了如何获得最大文档滚动值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一些插件,我需要获得文件的最大值 scrollTop 值。
最大 scrollTop 值是 2001 ,但 $(文件).height( )返回 2668 $('body')[0] .scrollHeight 给我 undefined

I am making some plugin and I need to get maximum scrollTop value of the document. Maximum scrollTop value is 2001 , but $(document).height() returns 2668 and $('body')[0].scrollHeight gives me undefined.

如何通过javascript /获取 2001 jquery?!

How to get 2001 through javascript/jquery?!

推荐答案

评论中的代码应该有效:

The code in your comments should work:

$(document).height() - $(window).height()

以下是滚动到最大滚动位置时发出警报的示例: http://jsfiddle.net/DWn7Z/

Here's an example that alerts when you scroll to the maximum scroll position: http://jsfiddle.net/DWn7Z/

这篇关于如何获得最大文档滚动值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆