JQuery實(shí)例:offsetWidth 與 offsetHeight
來源:程序員人生 發(fā)布時(shí)間:2013-10-18 02:46:30 閱讀次數(shù):3538次
網(wǎng)(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.vxbq.cn/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>
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)