How does jquery determine that the scroll bar has reached the bottom and top?

Source: Internet
Author: User

Copy codeThe Code is as follows:
$ (Document). height () // gets the height of the entire page
$ (Window). height () // gets the height of the page that the browser can see. This size will change when you zoom in the browser window, which is different from the document size.

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

To get the bottom end, you only need to get scrollTop () >=$ (document). height ()-$ (window). height () to know the end of the scroll;
Copy codeThe Code is as follows:
$ (Document). scrollTop () gets the vertical scroll distance, that is, the distance from the top of the current tumble window to the top of the entire page;
$ (Document). scrollLeft () This is the distance to obtain the horizontal scroll bar;

Example:
Copy codeThe Code is as follows:
$ (Document). scroll (function (){
$ ("# Lb"). text ($ (document). scrollTop ());
})
<Span id = "lb" style = "top: 100px; left: 100px; position: fixed;"> </span> <! -- When a fixed span mark is rolled -->

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.