jQuery nextAll method


jQuery “nextAll()” method is used to get all the next siblings of the matched elements.


Syntax : jQuery nextAll() method

$(selector).nextAll(selector-element);

selector-element : Is optional, you can add selector-element to get next element.

jQuery nextAll Method Example 1

jQuery nextAll() Method Syntax

<script type="text/javascript">
         $(document).ready(function(){ 
              $( "#selectNextAll" ).on( "click", function(event) {             
                 $(".curr-li").nextAll().css("border","1px solid red");
              });
               
          });
</script>

Try it »

jQuery nextAll Method Example 2

jQuery nextAll() Method Syntax

<script type="text/javascript">
         $(document).ready(function(){ 
              $( "#selectNextAll" ).on( "click", function(event) {             
                 $("li").nextAll("span").css("background","yellow");
              });
               
          });
</script>

Try it »


Add Comment

📖 Read More


Advertisements