Opposite of “scrollTop” in jQuery

前端 未结 8 956
情深已故
情深已故 2020-12-14 08:04

jQuery has a function called scrollTop which can be used to find the number of pixels hidden above the current page view.

I\'m not really sure why, but there is no s

8条回答
  •  一个人的身影
    2020-12-14 08:15

    You could make a pretty simple plugin for this:

    $.fn.scrollBottom = function() { 
      return $(document).height() - this.scrollTop() - this.height(); 
    };
    

    Then call it on whatever element you wanted, for example:

    $(window).scrollBottom();  //how many pixels below current view
    $("#elem").scrollBottom(); //how many pixels below element
    

提交回复
热议问题