jQuery的height、innerHeight、outerHeight三者的区别
贴代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Height</title>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
#odiv{
width:100px;
height:400px;
border:2px solid blue;
padding:15px;
margin:30px;
background-color:red;
}
</style>
<script type="text/javascript">
$(function(){
var odiv=$("#odiv");
console.log(odiv.height());
//height 400
console.log(odiv.innerHeight());
//height+padding 430
console.log(odiv.outerHeight());
//height+padding+border 434
console.log(odiv.outerHeight(true));
//height+padding+border+margin 494
});
</script>
</head>
<body>
<div id="odiv">
</div>
</body>
</html>