- 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 - childElements() Method
Collects all of the element's children and returns them as an array of extended elements.
An index of 0 refers to the topmost child of an element.
Syntax
element.childElements();
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').childElements();
arr.each(function(node) {
alert(node.nodeName + ': ' + node.innerHTML);
});
}
</script>
</head>
<body>
<div id = "father">
<p id = "kid1">This is first paragraph</p>
<p id = "kid2">This is second paragraph</p>
</div>
<br />
<input type = "button" value = "showElements" onclick = "showElements();"/>
</body>
</html>
Output
prototype_element_object.htm
Advertisements