Jquery-traversal-nextall

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

jQuery-nextAll([セレクタ])メソッド

説明

  • nextAll([selector])*メソッドは、現在の要素の後のすべての兄弟要素を検索します。

構文

このメソッドを使用するための簡単な構文は次のとおりです-

selector.nextAll( [selector] )

パラメーター

これは、この方法で使用されるすべてのパラメータの説明です-

  • selector -CSS 1-3セレクター構文を使用して、オプションのセレクターを作成できます。 セレクターを指定すると、結果が除外されます。

以下は、このメソッドの使用方法を示す簡単な例です-

<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript"
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>

      <script type = "text/javascript" language = "javascript">
         $(document).ready(function(){
            $("div:first").nextAll().addClass("hilight");
         });
      </script>

      <style>
         .hilight { background:yellow; }
      </style>
   </head>

   <body>
      <div>first</div>
      <div>sibling<div>child</div></div>
      <div>sibling</div>
      <div>sibling</div>
   </body>
</html>

これにより、次の結果が生成されます–

以下は、このメソッドの使用方法を示す簡単な例です-

<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript"
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>

      <script type = "text/javascript" language = "javascript">
         $(document).ready(function(){
            $("div:first").nextAll().addClass("hilight");
         });
      </script>

      <style>
         .hilight { background:yellow; }
      </style>
   </head>

   <body>
      <div>first</div>
      <div  class = "hilight">sibling<div>child</div></div>
      <div  class = "hilight">sibling</div>
      <div  class = "hilight">sibling</div>
   </body>
</html>

これにより、次の結果が生成されます–