offsetWidth 与offsetHeight

<html>
<head>
 <title>Untitled</title>
 <style type="text/css">
 #div1
 {
   border:10px solid red;
   200px;
   height:80px;
   margin:20px;
   padding:10px;
 }
    </style>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
    window.onload = function(){
       $("#div1").html("offsetWidth:" + $("#div1").get(0).offsetWidth + "<br/>offsetHeight:" + $("#div1").get(0).offsetHeight);
    }
    </script>
</head>

<body>
<div id="div1">
Hello World!
</div>
</body>
</html>

offsetWidth 与offsetHeight 只包含border + padding + content 的宽度。

原文地址:https://www.cnblogs.com/weekend001/p/1604758.html