Jquery's way of determining that the scroll bar has reached the bottom and top

  • 2020-03-30 02:31:55
  • OfStack

$(document).height()  //Is to get the height of the entire page
$(window).height()  //Gets the height of the part of the page that is currently visible to the browser. This size changes when you scale the browser window, not the same as a document

To get the top, all you have to do is get the top when scrollTop()==0;

To get the bottom, just get scrollTop()> = $(document), height () - $(window), height ()   I know I'm at the bottom;

$(document).scrollTop()  Gets the distance of the vertical scroll    That is, the distance between the top of the window and the top of the entire page where the current scroll is located; 
$(document).scrollLeft()  This is the distance to get the horizontal scroll bar; 


<span id="lb" style="top:100px;left:100px;position:fixed;"></span><!-- A fixed span tag   When rolling -->

Related articles: