返回到:Prototype – 元素对象
此方法查找并返回元素的计算高度。
对于在内联样式规则或 CSS 样式表中显示设置为 none 的元素,此方法返回正确的值。
请注意,返回的值只是一个数字,尽管它以像素表示。
语法
element.getHeight();
返回值
它返回元素的计算高度。
例子
HTML
x
25
25
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function showResult() {
8
var height = $('rectangle').getHeight();
9
alert("Element height is " + height );
10
}
11
</script>
12
</head>
13
14
<body>
15
<p>Click the button to see the result.</p>
16
17
<div id = "rectangle"
18
style = "font-size: 10px; width: 20em; height: 10em">
19
<p>This is the paragraph.</p>
20
</div>
21
<br />
22
23
<input type = "button" value = "showResult" onclick = "showResult();"/>
24
</body>
25
</html>
返回到:Prototype – 元素对象
阅读剩余 78%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9105.html