Get element outer width

Description

The following code shows how to get element outer width.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type='text/javascript'>
  $(document).ready(function() {<!--  ww  w .  j  a v a2  s  .  co m-->
    alert('outerWidth: ' + $('div').outerWidth({
      margin : true
    }) + "\n" + 'outerHeight: ' + $('div').outerHeight({
      margin : true
    }));
  });
</script>
<style type='text/css'>
div {
  width: 200px;
  height: 200px;
  padding: 10px;
  border: 1px solid rgb(200, 200, 200);
  background: lightblue;
  margin: 10px;
}
</style>
</head>
<body>
  <div>java2s.com</div>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities