Tutorials Point


  Learn Prototype
  Prototype Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Prototype childElements() Method


previous next AddThis Social Bookmark Button


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:

  • 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>

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



previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names