---
id: api/commands/nextall
title: nextAll | Cypress Documentation
description: >-
  Get all following siblings of each DOM element in a set of matched DOM
  elements in Cypress.
section: api
source_path: docs/api/commands/nextall.mdx
version: 6a908a532b1fca4ed18538a4c1c5a9bc7f24f403
updated_at: '2026-05-01T19:25:18.656Z'
---
# nextAll

Get all following siblings of each DOM element in a set of matched DOM elements.

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

## Syntax

```
.nextAll().nextAll(selector).nextAll(options).nextAll(selector, options)
```

### Usage

**Correct Usage**

```
cy.get('.active').nextAll() // Yield all links next to `.active`
```

**Incorrect Usage**

```
cy.nextAll() // Errors, cannot be chained off 'cy'cy.getCookies().nextAll() // Errors, 'getCookies' does not yield DOM element
```

### Arguments

**selector _(String selector)_**

A selector used to filter matching DOM elements.

**options _(Object)_**

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

| 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 `.nextAll()` to resolve before [timing out](#Timeouts) |

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

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

## Examples

### No Args

#### Find all of the element's siblings following `.second`

```
<ul>  <li>apples</li>  <li class="second">oranges</li>  <li>bananas</li>  <li>pineapples</li>  <li>grapes</li></ul>
```

```
// yields [<li>bananas</li>, <li>pineapples</li>, <li>grapes</li>]cy.get('.second').nextAll()
```

### Selector

#### Find all of the following siblings of each li. Keep only the ones with a class `selected`

```
<ul>  <li>apples</li>  <li>oranges</li>  <li>bananas</li>  <li class="selected">pineapples</li>  <li>grapes</li></ul>
```

```
// yields <li>pineapples</li>cy.get('li').nextAll('.selected')
```

## Rules

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

*   `.nextAll()` 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)

*   `.nextAll()` 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).
*   `.nextAll()` 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)

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

## Command Log

**_Find all elements following the `.active` li_**

```
cy.get('.left-nav').find('li.active').nextAll()
```

The commands above will display in the Command Log as:

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

## See also

*   [`.next()`](/llm/markdown/api/commands/next.md)
*   [`.nextUntil()`](/llm/markdown/api/commands/nextuntil.md)
*   [`.prevAll()`](/llm/markdown/api/commands/prevall.md)
