- Prototype Tutorial
- Prototype - Home
- Prototype - Short Overview
- Prototype - Useful Features
- Prototype - Utility Methods
- Prototype - Element Object
- Prototype - Number Processing
- Prototype - Strings Processing
- Prototype - Array Processing
- Prototype - Hash processing
- Prototype - Basic Object
- Prototype - Templating
- Prototype - Enumerating
- Prototype - Event Handling
- Prototype - Form Management
- Prototype - JSON Support
- Prototype - AJAX Support
- Prototype - Expressing Ranges
- Prototype - Periodical Execution
- Prototype Useful Resources
- Prototype - Quick Guide
- Prototype - Useful Resources
- Prototype - Discussion
Prototype - descendants() Method
This method collects all of element's descendants and returns them as an array of extended elements.
Note that all of Prototype's DOM traversal methods ignore text nodes and return element nodes only.
Syntax
element.descendants() ;
Return Value
An array of HTML elements.
Example
<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>
Output
prototype_element_object.htm
Advertisements
To Continue Learning Please Login
Login with Google