Prototype-element-nextsiblings

提供:Dev Guides
移動先:案内検索

プロトタイプ-nextSiblings()メソッド

このメソッドは、要素の次の兄弟をすべて収集し、それらを拡張要素の配列として返します。

-2つの要素が同じ親を持つ場合、それらは兄弟です。

構文

element.nextSiblings();

戻り値

HTML要素の配列。

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

出力