Learn Prototype
Prototype Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
Prototype nextSiblings() Method
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:
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.
|
|
|