Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Select all Siblings after a child

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 380
    Comment on it

    In jQuery, to select all siblings div after a child we use a function nextAll().

    Syntax:

    $(element).nextAll();
    

    For example:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="main">
    
          <div id="one">First div</div>
          <div id="two">Second div</div>
          <div id="three">Third div</div>
          <div id="four">Fourth div</div>
    
    </div>
    

    In above code, we need to change the background color of all the div that are coming after the second div. For this you need to add the following script:

    <script type="text/javascript"> 
            $('#two').nextAll().css( "background-color", "blue" );
    </script>
    

 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: