jQuery nextAll() Method

## jQuery Tutorial

jQuery HOME jQuery Intro jQuery Install jQuery Syntax jQuery Selectors jQuery Events

## jQuery Effects

jQuery Hide/Show jQuery Fade jQuery Slide jQuery Animate jQuery stop() jQuery Callback jQuery Chaining

## jQuery HTML

jQuery Get jQuery Set jQuery Add jQuery Remove jQuery CSS Classes jQuery css() jQuery Dimensions

## jQuery Traversing

jQuery Traversing jQuery Ancestors jQuery Descendants jQuery Siblings jQuery Filtering

## jQuery AJAX

jQuery AJAX Intro jQuery Load jQuery Get/Post

## jQuery Misc

jQuery noConflict()

## jQuery Examples

jQuery Examples jQuery Quiz jQuery Certificate

## jQuery References

jQuery Selectors jQuery Events jQuery Effects jQuery HTML/CSS jQuery Traversing jQuery AJAX jQuery Misc jQuery Properties

# jQuery nextAll() Method

jQuery Traversing Methods

## Example

Return all next sibling elements of each <li> element with class name "start":

$(document).ready(function(){
$("li.start").nextAll().css({"color":"red","border":"2px solid red"});
});

Result:

ul (parent)
- li (sibling)
- li (sibling)
- li (sibling with class name "start")
- li (sibling)
- li (sibling)
- li (sibling)

Try it yourself »

## Definition and Usage

The nextAll() method returns all next sibling elements of the selected element.

Sibling elements are elements that share the same parent.

The DOM tree: This method traverse forward along siblings of DOM elements.

Related methods:

- next() - returns the next sibling element of the selected element
- nextUntil() - returns all next sibling elements between two given arguments

## Syntax

$(selector).nextAll(filter)

Parameter | Description
--- | ---
filter | Optional. Specifies a selector expression to narrow down the search for next siblings Note: To return multiple siblings, separate each expression with a comma.

## Try it Yourself - Examples

Narrow down the search
How to filter the search for next sibling elements.

Return multiple siblings
How to use the filter parameter to return all siblings of a <h2> element that have class names "1", "2" and "3".

Select all next sibling elements of a <p> element
How to select all next sibling elements of a <p> element.

Select all next sibling <p> elements of <div>
How to select all next sibling <p> elements of each <div> element.

jQuery Traversing Methods

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE