代码编辑器:
x
1
2
<meta charset="utf-8">
3
<link href="/static/next/css/tryit.css?v=2017082407" rel="stylesheet"/>
4
<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
5
<script>
6
$(document).ready(function(){
7
$("button").click(function(){
8
var txt="";
9
txt+="outerHeight() of div: " + $("div").outerHeight() + "</br>";
10
txt+="outerHeight(true) of div: " + $("div").outerHeight(true) + "</br>";
11
$("div").html(txt);
12
});
13
});
14
</script>
15
<div style="height:120px;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:lightblue;"></div><br>
16
<button>显示div的外部高度</button>
17
<p>outerHeight() - 返回元素的高度 (包括内部填充和边框)</p>
18
<p>outerHeight(true) - 返回元素的高度 (包括内部填充、边框和外填充)</p>