.outerHeight()
.outerHeight( [ includeMargin ] ) 返回: Integer
描述: 為匹配的元素集合中獲取第一個元素的當前計算高度值,包括padding,border和選擇性的margin。
-
version added: 1.2.6.outerHeight( [ includeMargin ] )
includeMargin一個表明是否在計算時包含元素的margin的布爾值。
在.outerHeight()
計算中總是包含padding-top ,padding-bottom 和 border-top,border-bottom ;如果includeMargin
參數(shù)是true
,那么margin (top 和 bottom)也會被包含。
這個方法不適用于window and document對象,可以使用.height()
代替。
例子:
獲取一個段落的outerHeight。
<!DOCTYPE html>
<html>
<head>
<style>p { margin:10px;padding:5px;border:2px solid #666; } </style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<p>Hello</p><p></p>
<script>var p = $("p:first");
$("p:last").text( "outerHeight:" + p.outerHeight() + " , outerHeight(true):" + p.outerHeight(true) );</script>
</body>
</html>