javascriptjqueryscrolltop

How to get maximum document scrolltop value


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.

How to get 2001 through javascript/jquery?!


Solution

  • The code in your comments should work:

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

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