(document). Height () and $ (window). Height ()

Source: Internet
Author: User

Http://www.cnblogs.com/piuba/archive/2013/01/06/2847295.html

The jquery (window). Height () represents the size of the currently visible area, and jquery (document). Height () represents the height of the entire document, and is used visually.

Note the jquery (window) When the browser window size changes (such as maximizing or pulling out the windows). Height () changes, but jquery (document). Height () is unchanged.

$ (document). ScrollTop () Gets the distance of the vertical scroll, which is the distance from the  top of the window to the top of the page
$ (document). ScrollLeft () This is the distance

to get the horizontal scroll bar To get the top only need to get to scrolltop () ==0  is the top.

to get the bottom, just get scrolltop () >=$ (document). Height ()-$ (window). Height ()  you will know that you have scrolled to the end

of $ (document). Height ()  //is the height of the entire page
$ (window). Height ()  //is to get the current That's the height of the page that you can see in your browser.  this size will change when you zoom in on the browser window and the document is different according to the  English should also be able to understand it

yourself to do an experiment to know the 
$ (document) . Scroll (function () {
    $ ("#lb"). Text ($ (document). ScrollTop ());
<span id= "lb" style= "top:100px;left:100px;position:fixed;" ></span><!--a fixed span marker to scroll for easy viewing-->

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.