- Prototype 教程
- Prototype - 主页
- Prototype - 简要概述
- Prototype - 实用功能
- Prototype - 实用方法
- Prototype - 元素对象
- Prototype - 数字处理
- Prototype - 字符串处理
- Prototype - 数组处理
- Prototype - 哈希处理
- Prototype - 基本对象
- Prototype - 模板化
- Prototype - 枚举
- Prototype - 事件处理
- Prototype - 表单管理
- Prototype - JSON 支持
- Prototype - AJAX 支持
- Prototype - 表达范围
- Prototype - 定期执行
- Prototype 实用资源
- Prototype - 快速指南
- Prototype - 实用资源
- Prototype - 讨论
Prototype - recursivelyCollect() 方法
此方法递归收集其关系由属性指定元素。属性必须指向单个 DOM 节点的元素属性。
语法
element.recursivelyCollect(property);
属性的值可为以下任意一种元素 −
- parentNode
- previousSibling
- nextSibling
返回值
返回 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_element_object.htm
广告