jQuery Style How to - Get outer width and outer height








Question

We would like to know how to get outer width and outer height.

Answer


<html>
  <head>
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type='text/javascript'>
$(document).ready(<!--   w  ww.j av  a 2s . c o m-->
  function() {
    console.log(
      'outerWidth: '  + $('div').outerWidth() + "\n" + 
      'outerHeight: ' + $('div').outerHeight()
    );
  }
);
    </script>
    <style type='text/css'>

div {
    width: 200px;
    height: 200px;
    padding: 10px;
    border: 1px solid rgb(200, 200, 200);
    background: lightblue;
}
    </style>
  </head>
  <body>
    <div></div>
  </body>
</html>

The code above is rendered as follows: