
- 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 - descendants() 方法
此方法收集元素的所有後代,並將其作為擴充套件元素陣列返回。
請注意,Prototype 的所有 DOM 遍歷方法都將忽略文字節點,只返回元素節點。
語法
element.descendants() ;
返回值
HTML 元素陣列。
示例
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showElements() { var arr = $('father').descendants(); arr.each(function(node) { alert(node.nodeName + ': ' + node.innerHTML); }); } </script> </head> <body> <p>Click descendants button to see the result.</p> <div id = "father"> <p id = "kid">This is first paragraph</p> </div> <br /> <input type = "button" value = "descendants" onclick = "showElements();"/> </body> </html>
輸出
prototype_element_object.htm
廣告