jquery determines whether the scrollbar reaches the top and bottom of the window

Source: Internet
Author: User

<script type= "Text/javascript" >$ (document). Ready (function () {    alert ($ (window). Height ()); The browser window currently has a visible area height of     alert ($ (document). Height ()); The height of the window document in the browser     alert ($ (document.body). Height ());//browser Current window document body altitude      alert ($ (document.body). Outerheight (True));//browser window The total height of the document body includes border padding margin    Alert ($ (window). width ()); The browser window currently has a viewable area width of     alert ($ (document). width ());//browser window document for image width      Alert ($ (document.body). width ());//browser Current window document body height     alert ($ (document.body). Outerwidth ( true);//browser window The total width of the document body includes border padding margin        var win_height=$ ( window). Height ();    var doc_height=$ (document). Height ();    var scroll_top=$ ( Document). ScrollTop ();       /*    doc_height is the height of the documentation, Scroll_ Top is the height of the scroll bar above the top of the document, Window_heighT indicates the height of the window.      when scroll_top = 0 o'clock, indicates that the scroll bar has reached the top of the window.      when Scroll_top + window_height >= doc_height, the scroll bar has reached the bottom of the window.     */    //Determines whether the scrollbar reaches the bottom of the window     $ (Windows). Bind (' scroll ', function ( ) {   //Bind scrolling event         if ($ (document). ScrollTop () + $ (window). Height () >= $ (document). Height ()) {            console.log (win_height);             console.log ($ (document). ScrollTop ());             console.log (doc_height);            //......       }    });   }) ;</script>


jquery determines whether the scrollbar reaches the top and bottom of the window

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.