---
id: api/commands/nextuntil
title: nextUntil | Cypress Documentation
description: >-
  Get all following siblings of each DOM element in a set of matched DOM
  elements up to, but not including, the element provided in Cypress.
section: api
source_path: docs/api/commands/nextuntil.mdx
version: 204dffbf7fbb64b1fe8343a54ddcd869cc275f1f
updated_at: '2026-05-12T20:33:17.938Z'
---
# nextUntil

Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.

The querying behavior of this command matches exactly how [`.nextUntil()`](http://api.jquery.com/nextUntil) works in jQuery.

## Syntax

```
.nextUntil(selector).nextUntil(selector, filter).nextUntil(selector, filter, options).nextUntil(element).nextUntil(element, filter).nextUntil(element, filter, options)
```

### Usage

**Correct Usage**

```
cy.get('div').nextUntil('.warning') // Yield siblings after 'div' until '.warning'
```

**Incorrect Usage**

```
cy.nextUntil() // Errors, cannot be chained off 'cy'cy.clock().nextUntil('path') // Errors, 'clock' does not yield DOM elements
```

### Arguments

**selector _(String selector)_**

The selector where you want finding next siblings to stop.

**element _(DOM node, jQuery Object)_**

The element where you want finding next siblings to stop.

**filter _(String selector)_**

A selector used to filter matching DOM elements.

**options _(Object)_**

Pass in an options object to change the default behavior of `.nextUntil()`.

| Option | Default | Description |
| --- | --- | --- |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.nextUntil()` to resolve before [timing out](#Timeouts) |

### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)

*   `.nextUntil()` yields the new DOM element(s) it found.
*   `.nextUntil()` is a query, and it is _safe_ to chain further commands.

## Examples

### Selector

#### Find all of the element's siblings following `#veggies` until `#nuts`

```
<ul>  <li id="fruits" class="header">Fruits</li>  <li>apples</li>  <li>oranges</li>  <li>bananas</li>  <li id="veggies" class="header">Vegetables</li>  <li>cucumbers</li>  <li>carrots</li>  <li>corn</li>  <li id="nuts" class="header">Nuts</li>  <li>walnuts</li>  <li>cashews</li>  <li>almonds</li></ul>
```

```
//returns [<li>cucumbers</li>, <li>carrots</li>, <li>corn</li>]cy.get('#veggies').nextUntil('#nuts')
```

## Rules

### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)

*   `.nextUntil()` requires being chained off a command that yields DOM element(s).

### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)

*   `.nextUntil()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until the element(s) [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).
*   `.nextUntil()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed.

### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)

*   `.nextUntil()` can time out waiting for the element(s) to [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).
*   `.nextUntil()` can time out waiting for assertions you've added to pass.

## Command Log

**_Find all of the element's siblings following `#veggies` until `#nuts`_**

```
cy.get('#veggies').nextUntil('#nuts')
```

The commands above will display in the Command Log as:

When clicking on `nextUntil` within the command log, the console outputs the following:

## See also

*   [`.next()`](/llm/markdown/api/commands/next.md)
*   [`.nextAll()`](/llm/markdown/api/commands/nextall.md)
*   [`.parentsUntil()`](/llm/markdown/api/commands/parentsuntil.md)
*   [`.prevUntil()`](/llm/markdown/api/commands/prevuntil.md)
