Copyright © tutorialspoint.com

Prototype childElements() Method

previous next


Advertisements

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 element.

Syntax:

element.childElements();

Return Value:

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>

To understand it in better way you can Try it yourself.


previous next

Copyright © tutorialspoint.com