From jQuery JavaScript Library
« Back to CSS
outerWidth( [margin] )
Get the outer width (includes the border and padding by default) for the first matched element.
This method works for both visible and hidden elements. It is not supported for elements that are indirectly hidden by consequence of a parent being hidden. Please use .width() for the window and document.
Arguments:| margin (Optional) | Boolean | |
|---|
| When set to true the margin of the element will be included in the calculations. |
Examples:| Name | Type |
Get outerWidth
var p = $("p:first");
$("p:last").text( "outerWidth:" + p.outerWidth()+ " , outerWidth(true):" + p.outerWidth(true) );
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var p = $("p:first");
$("p:last").text( "outerWidth:" + p.outerWidth()+ " , outerWidth(true):" + p.outerWidth(true) );
});
</script>
<style>
p { margin:10px;padding:5px;border:2px solid #666; }
</style>
</head>
<body>
<p>Hello</p><p></p>
</body>
</html>