tadam logo
Did you find an error in the text?
Select this with mouse and press
Ctrl + Enter
Xhtml.co.il Check Spelling
Orphus system

outerWidth()

outerWidth( [ includeMargin ] )

Returns: Integer
version added: 1.2.6

Arguments

includeMargin
A Boolean indicating whether to include the element's margin in the calculation.
Description: Get the current computed width for the first element in the set of matched elements, including padding and border.

If includeMargin is omitted or false, the padding and border are included in the calculation; if true, the margin is also included.

This method is not applicable to window and document objects; for these, use .width() instead.

css outerWidth jQuery

Example

Get the outerWidth of a paragraph.
var p = $("p:first");
$("p:last").text( "outerWidth:" + p.outerWidth() + 
   " , outerWidth(true):" + p.outerWidth(true) );
The output of the code above will be:
Full source:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
  <style>p { margin:10px;padding:5px;border:2px solid #666; } </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>

<script type="text/javascript" language="javascript">
$(document).ready(function(){
var p = $("p:first");
$("p:last").text( "outerWidth:" + p.outerWidth() + 
   " , outerWidth(true):" + p.outerWidth(true) );
  });
</script>

</head>

<body>

<p>Hello</p><p></p>
</body>
</html>
Was this information helpful?
   

Comments