Check scroll y position and offset height - Javascript jQuery

Javascript examples for jQuery:Width Height

Description

Check scroll y position and offset height

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script> 
  <style id="compiled-css" type="text/css">

html, body{
   height: 2000px;
}


      </style> 
 </head> /*from w  w  w .  ja v a  2s.  c  o  m*/
 <body> 
  <script>
$(window).scroll(function() {
  if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight ) {
   console.log("at the bottom of page");
  }
 });

      </script>  
 </body>
</html>

Related Tutorials