jQuery nextUntil()Method
Examples
Return all sibling elements between the two <li> elements with the class names "start" and "stop":
Result:
- ul (parent)
- li (sibling)
- li (sibling)
- li (sibling with class name "start")
- li (sibling)
- li (sibling)
- li (sibling)
- li (sibling with class name "stop")
Try it Yourself »
Definition and Usage
The nextUntil() method returnsselectorandstopall sibling elements after each element in between.
Sibling elements are elements that share the same parent element.
DOM tree:This method traverses forward along the sibling elements of DOM elements.
Note:If both parameters are empty, the method will return all sibling elements after the element (same asnextAll()the method).
Related methods:
- next()- Return the next sibling element of the selected element
- nextAll()- Return all sibling elements after the selected element
Syntax
| Parameter | Description |
|---|---|
| stop | Optional. A selector expression, element, or jQuery object indicating where to stop searching for matching sibling elements after the element. |
| filter | Optional. Specifies to narrow the search betweenselectorandstopthe selector expression for the range of sibling elements between. Note:To return multiple sibling elements, use a comma to separate each expression. |
More Examples
Narrowing the search range
Use two parameters to filter the search for sibling elements after each element between two parameters.
Return multiple sibling elements
How to return multiple sibling elements between two parameters.
DOM
Use DOM elements instead of selectors to return all sibling elements between two given parameters.
Using DOM with two parameters
Use DOM with two parameters instead of selectors to filter the search for sibling elements after each element between two parameters.
Other Extensions
jQuery Traversal Methods