返回到:Prototype – 元素对象
此方法递归地收集其关系由属性指定的元素。属性必须是指向单个 DOM 节点的元素的属性。
语法
element.recursivelyCollect(property);
财产的价值可以是以下任何一项 –
- parentNode
- previous兄弟姐妹
- 下一个兄弟姐妹
返回值
返回一个 HTML 元素数组。
例子
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showResult() { var arr = $('fruits').recursivelyCollect('nextSibling'); arr.each(function(node) { alert(node.nodeName + ': ' + node.innerHTML); }); } </script> </head> <body> <p>Click the button to see the result.</p> <ul id = "fruits"> <li id = "apples"> <ul id = "list-of-apples"> <li id = "golden"><p>Golden</p></li> <li id = "mutsu">Mutsu</li> <li id = "mcintosh">McIntosh</li> <li id = "ida-red">Ida Red</li> </ul> </li> </ul> <p>This is the paragraph</p> <br /> <input type = "button" value = "Show Result" onclick = "showResult();"/> </body> </html>
返回到:Prototype – 元素对象
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9045.html