Home  >  Article  >  Web Front-end  >  jquery method to determine whether the scroll bar has reached the bottom or top_jquery

jquery method to determine whether the scroll bar has reached the bottom or top_jquery

WBOY
WBOYOriginal
2016-05-16 16:53:531019browse

Copy code The code is as follows:

$(document).height() //is to get The height of the entire page
$(window).height() // is to get the height of the current part of the page that the browser can see. This size will change when you resize the browser window, which is different from the document

To get the top, you only need to get the top when scrollTop()==0;

To get the bottom, just get scrollTop()>=$(document).height()-$(window).height() Then you will know that you have scrolled to the bottom;

Copy code The code is as follows:

$(document).scrollTop() Gets the vertical scrolling distance, which is the window where the current scroll is The distance from the top to the top of the entire page;
$(document).scrollLeft() This is the distance to get the horizontal scroll bar;

Example:
Copy code The code is as follows:

$(document).scroll(function(){
$("#lb").text ($(document).scrollTop());
})

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn