返回到:Prototype – 元素对象
此方法递归地收集其关系由属性指定的元素。属性必须是指向单个 DOM 节点的元素的属性。
语法
element.recursivelyCollect(property);
财产的价值可以是以下任何一项 –
- parentNode
- previous兄弟姐妹
- 下一个兄弟姐妹
返回值
返回一个 HTML 元素数组。
例子
HTML
x
34
34
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 arr = $('fruits').recursivelyCollect('nextSibling');
9
arr.each(function(node) {
10
alert(node.nodeName + ': ' + node.innerHTML);
11
});
12
}
13
</script>
14
</head>
15
16
<body>
17
<p>Click the button to see the result.</p>
18
19
<ul id = "fruits">
20
<li id = "apples">
21
<ul id = "list-of-apples">
22
<li id = "golden"><p>Golden</p></li>
23
<li id = "mutsu">Mutsu</li>
24
<li id = "mcintosh">McIntosh</li>
25
<li id = "ida-red">Ida Red</li>
26
</ul>
27
</li>
28
</ul>
29
<p>This is the paragraph</p>
30
<br />
31
32
<input type = "button" value = "Show Result" onclick = "showResult();"/>
33
</body>
34
</html>
返回到:Prototype – 元素对象
阅读剩余 52%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9045.html