jQuery Style How to - Get element outer height








Question

We would like to know how to get element outer height.

Answer


<!--   w  w  w.  j  a v a2  s.  c  o  m-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
             $("div").width(300);
             console.log($("div").outerHeight());
        });
    </script>
    <style>
    div{
        width:200px;
        height:100px;
        overflow:auto;
    }
    h1 { width:1000px;height:1000px; }
  </style>

  </head>
  <body>
       <div><h1>header 1</h1></div>
    </body>
</html>

The code above is rendered as follows: