Easy Tutorial
❮ Event Data Event Pagex ❯

jQuery nextUntil() Method

jQuery Traversing Methods

Example

Returns all sibling elements between two <li> elements with class names "start" and "stop":

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

Result:


Definition and Usage

The nextUntil() method returns all sibling elements following each element, up to but not including the element matched by the selector and stop.

Sibling elements are elements that share the same parent.

DOM Tree: This method traverses forward along the sibling elements of the DOM elements.

Note: If both parameters are empty, the method will return all sibling elements following the element (same as the nextAll() method).

Related methods:


Syntax

Parameter Description
stop Optional. A selector expression, element, or jQuery object indicating where to stop matching following sibling elements.
filter Optional. A selector expression to narrow down the search for sibling elements between the selector and stop. <br> <br> Note: To return multiple sibling elements, separate each expression with a comma.

More Examples

Narrow Down the Search

Return Multiple Sibling Elements

DOM

Using DOM with Two Parameters


jQuery Traversing Methods

❮ Event Data Event Pagex ❯