Difference between $(window).width() vs $(document).width() - Javascript jQuery

Javascript examples for jQuery:Width Height

Description

Difference between $(window).width() vs $(document).width()

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://code.jquery.com/jquery-1.7.1.js"></script> 
      <style id="compiled-css" type="text/css">

html { width: 1000px; }


      </style> 
      <script type="text/javascript">
    $(window).load(function(){//from ww  w  .j  av a2 s . c om
console.log($(window).width());
console.log($(document).width());
    });

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

Related Tutorials