05 - outerHeight、outerWidth 和 innerWidth、innerHeight 和 width() height()
一、jQuery方法 outerWidth() 和 outerHeight() 1. outerWidth() - 方法返回 第一个匹配元素的外部宽度。 - 返回 第一个匹配元素的外部宽度。该宽度= content + padding + border - 如需包含 margin,使用 outerWidth(true)。该宽度= content + padding + border + margin <style> .box { width: 200px; height: 200px; padding: 20px; border: 4px solid red; margin: 20px; } </style> <div class="content"> <div class="box">boxbox</div> </div> <script> console.log($('.box').outerWidth()); // 248 console.log($('.box').outerWidth(true)); // 288 </script> 2.outHeight() - 方法返回 第一个匹配元素的外部高度。 - 返回 第一个匹配元素的外部宽度。该宽度= content + padding + border - 如需包含 margin,使用 outerWidth(true)