
.innerWidth()
描述: 为匹配的元素集合中获取第一个元素的当前计算宽度值,包括padding,但是不包括border。
添加的版本: 1.2.6.innerWidth()
这个方法不接受任何参数。
这个方法返回元素的宽度,包括左边和右边的padding,单位是像素。
这个方法不适用于window and document对象,可以使用.width() 代替。
例子:
获取段落的innerWidth。
<!DOCTYPE html>
<html>
<head>
<style>p { margin:10px;padding:5px;border:2px solid #666; } </style>
<script src="https://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p>Hello</p><p></p>
<script>var p = $("p:first");
$("p:last").text( "innerWidth:" + p.innerWidth() );</script>
</body>
</html>
|