返回到:Prototype – 元素对象
收集元素的所有子元素并将它们作为扩展元素数组返回。
索引 0 表示元素的最顶层子元素。
语法
element.childElements();
返回值
一组 HTML 元素。
例子
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 showElements() {
8
var arr = $('father').childElements();
9
arr.each(function(node) {
10
alert(node.nodeName + ': ' + node.innerHTML);
11
});
12
}
13
</script>
14
</head>
15
16
<body>
17
<div id = "father">
18
<p id = "kid1">This is first paragraph</p>
19
<p id = "kid2">This is second paragraph</p>
20
</div>
21
<br />
22
23
<input type = "button" value = "showElements" onclick = "showElements();"/>
24
</body>
25
</html>
返回到:Prototype – 元素对象
阅读剩余 78%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9145.html