jQuery - nextAll ([selector]), méthode

La description

le nextAll( [selector] ) La méthode trouve tous les éléments frères après l'élément actuel.

Syntaxe

Voici la syntaxe simple pour utiliser cette méthode -

selector.nextAll( [selector] )

Paramètres

Voici la description de tous les paramètres utilisés par cette méthode -

  • selector- Le sélecteur facultatif peut être écrit en utilisant la syntaxe du sélecteur CSS 1-3. Si nous fournissons un sélecteur, le résultat sera filtré.

Exemple

Voici un exemple simple montrant l'utilisation de cette méthode -

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

Cela produira le résultat suivant -

Exemple

Voici un exemple simple montrant l'utilisation de cette méthode -

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

Cela produira le résultat suivant -

jquery-traversing.htm