.outerHeight()

.outerHeight( [ includeMargin ] ) 官网原E文: Integer

描述: 为匹配的元素集合中获取第一个元素的当前计算高度值,包括padding,border和选择性的margin。

  • version added: 1.2.6.outerHeight( [ includeMargin ] )

    includeMargin一个表明是否在计算时包含元素的margin的布尔值。

.outerHeight()计算中总是包含padding-top ,padding-bottom 和 border-top,border-bottom ;如果includeMargin参数是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>

Demo:

jQuery 1.6 API 中文版Clove整理、修订