jQuery Style How to - Check the difference between document height and window height








Question

We would like to know how to check the difference between document height and window height.

Answer


    <!--from  w w  w .j a v  a  2 s . c o m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.7.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    console.log ($(document).height() - $(window).height());
});
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: