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()); //浏览器时下窗口可视区域高度      alert($(document).height()); //浏览器时下窗口文档的高度      alert($(document.body).height()); //浏览器时下窗口文档body的高度      alert($(document.body).outerHeight( true )); //浏览器时下窗口文档body的总高度 包括border padding margin      alert($(window).width()); //浏览器时下窗口可视区域宽度      alert($(document).width()); //浏览器时下窗口文档对于象宽度      alert($(document.body).width()); //浏览器时下窗口文档body的高度      alert($(document.body).outerWidth( true )); //浏览器时下窗口文档body的总宽度 包括border padding margin           var win_height=$(window).height();      var doc_height=$(document).height();      var scroll_top=$(document).scrollTop();           /*      doc_height是文档的高度,scroll_top是滚动条上部离文档顶部的高度,window_height表示窗口高度。      当scroll_top == 0 时,表示滚动条已经到达窗口顶部。      当scroll_top + window_height >= doc_height 时,表示滚动条已经到达窗口底部。      */      //判断滚动条是否到达窗口底部      $(window).bind( ‘scroll‘ , function (){    //绑定滚动事件          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.