---
id: api/commands/parents
title: parents | Cypress Documentation
description: Get the parent DOM elements of a set of DOM elements in Cypress.
section: api
source_path: docs/api/commands/parents.mdx
version: 7ada28c0cd90e81cf56fd3fc73de6e6d45c16de6
updated_at: '2026-05-13T21:55:41.935Z'
---
# parents

Get the parent DOM elements of a set of DOM elements.

Please note that `.parents()` travels multiple levels up the DOM tree as opposed to the [.parent ()](/llm/markdown/api/commands/parent.md) command which travels a single level up the DOM tree.

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

## Syntax

```
.parents().parents(selector).parents(options).parents(selector, options)
```

### Usage

**Correct Usage**

```
cy.get('aside').parents() // Yield parents of aside
```

**Incorrect Usage**

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

### 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 `.parents()`.

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

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

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

## Examples

### No Args

#### Get the parents of the active li

```
<ul class="main-nav">  <li>Overview</li>  <li>    Getting started    <ul class="sub-nav">      <li>Install</li>      <li class="active">Build</li>      <li>Test</li>    </ul>  </li></ul>
```

```
// yields [.sub-nav, li, .main-nav]cy.get('li.active').parents()
```

### Selector

#### Get the parents with class `main-nav` of the active li

```
// yields [.main-nav]cy.get('li.active').parents('.main-nav')
```

## Rules

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

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

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

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

## Command Log

**_Get the parents of the active `li`_**

```
cy.get('li.active').parents()
```

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

## See also

*   [`.children()`](/llm/markdown/api/commands/children.md)
*   [`.parent()`](/llm/markdown/api/commands/parent.md)
*   [`.parentsUntil()`](/llm/markdown/api/commands/parentsuntil.md)
