网(LieHuo.Net)教程 offsetWidth 与offsetHeight 只包含border + padding + content 的宽度。
<html>
<head>
<title>WelCome to Liehuo.Net</title>
<style type="text/css">
#div1
{
border:10px solid red;
width:200px;
height:80px;
margin:20px;
padding:10px;
}
</style>
<script type="text/javascript" src="http://www.wfuyu.com/uploads/Common/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">
WelCome to Liehuo.Net
</div>
</body>
</html>