- 论坛徽章:
- 0
|
$.fn.outerWidth()
$.fn.innerWidth()
$.fn.outerHeight()
$.fn.innerHeight()
$.fn.width(), $.fn.height() 按W3C标准,只取块级元素的宽度或高度
(不包括 padding border).
$.fn.innerWidth, $fn.innerHeight (padding + $.fn.[width|height]).
$.fn.outerWidth, $fn.outerHeight (border + padding + $.fn.[width|height]),
如果指定 margin 属性(margin + border + padding + $.fn.[width|height]).
![]()
<style type="text/css">
#myTest {
margin: 10px;
padding: 10px;
border: 10px solid red;
width: 100px;
height: 100px;
background-color: black;
}
</style>
<div id="myTest"></div>
<script language="javascript">
jQuery.each(['width', 'height', 'innerWidth', 'innerHeight', 'outerWidth', 'outerHeight'],
function(k, v) {
console.log($('#myTest')[v]());
if ('outerWidth' == v || 'outerHeight' == v) {
console.log($('#myTest')[v](true));
}
}
);
//100, 100, 120, 120, 140, 160, 140, 160
</script> |
|