Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuery nextAll() Method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 514
    Comment on it

    The jQuery nextAll() method gives back all next sibling components of the  component which we have selected.

    By using nextAll() method we can select  all the  next siblings of the component which we have selected and then we can use them.

    Syntax

    selector.nextAll()

    selector − it is used to select html elements in which jquery has to be applied by using either id , class or html elements.

    nextAll() method also have an optional parameter which is explain below.

    selector.nextAll( [selector] )

    The selector which is  inside a brackets is  optional parameter which is used to filter the search for sibling.

    Below is the example for JQuery nextAll() method:-

    <html>
    <head>
    <style>
    body * { 
        display: block;
        border: 3px solid lightgrey;
        color: grey;
        padding: 6px;
        margin: 16px;
    }
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("h1").nextAll().css({"color": "#4FB053", "border": "1px solid #4FB053"});
    });
    </script>
    </head>
    <body>
    <div>parent div
      <p>para</p>
      <span>span</span>
      <h1>heading</h1>
      <p>para</p>
      <p>para</p>
    </div>
    </body>
    </html>

    In above example we are selecting  all the next sibling of the <h1> tag with the help of jQuery nextAll() method and then making its color green.

    Working demo:- https://jsfiddle.net/069bgj0u/1/

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: