Tutorials Point


  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Prototype nextSiblings() Method


previous next AddThis Social Bookmark Button


Advertisements

This method collects all of element's next siblings and returns them as an array of extended elements.

NOTE: Two elements are siblings if they have the same parent.

Syntax:

element.nextSiblings();

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 showResult(){
   var str = $('mutsu').nextSiblings();
   alert( "$('mutsu').nextSiblings() " + str[0].innerHTML );
   alert( "$('mutsu').nextSiblings() " + str[1].innerHTML );
   
   var str = $('ida-red').nextSiblings();
   alert( "$('ida-red').nextSiblings() " + str[0] );
  
 }

</script>
</head>

<body>

  <p>Click the button to see the result.</p>

  <ul>
     <li id="golden-delicious">Golden Delicious</li>
     <li id="mutsu">Mutsu</li>
     <li id="mcintosh">McIntosh</li>
     <li id="ida-red">Ida Red</li>
  </ul>

  <br />
  <input type="button" value="Click" onclick="showResult();"/>

</body>
</html>

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



previous next Printer Friendly

Advertisements


  

Advertisements