---
id: api/commands/eq
title: eq | Cypress Documentation
description: Get a DOM element at a specific index in an array of elements in Cypress.
section: api
source_path: docs/api/commands/eq.mdx
version: fa8f60eba6ec9a949b75fe9f9f5f6591719cd01f
updated_at: '2026-05-05T21:21:10.048Z'
---
# eq

Get A DOM element at a specific index in an array of elements.

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

## Syntax

```
.eq(index).eq(indexFromEnd).eq(index, options).eq(indexFromEnd, options)
```

### Usage

**Correct Usage**

```
cy.get('tbody>tr').eq(0) // Yield first 'tr' in 'tbody'cy.get('ul>li').eq(4) // Yield fifth 'li' in 'ul'
```

**Incorrect Usage**

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

### Arguments

**index _(Number)_**

A number indicating the index to find the element at within an array of elements. Starts with 0.

**indexFromEnd _(Number)_**

A negative number indicating the index position from the end to find the element at within an array of elements.

**options _(Object)_**

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

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

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

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

## Examples

### Index

#### Find the 2nd element within the elements

```
<ul>  <li>tabby</li>  <li>siamese</li>  <li>persian</li>  <li>sphynx</li>  <li>burmese</li></ul>
```

```
cy.get('li').eq(1).should('contain', 'siamese') // true
```

#### Make an assertion on the 3rd row of a table

```
<table>  <tr>    <th>Breed</th>    <th>Origin</th>  </tr>  <tr>    <td>Siamese</td>    <td>Thailand</td>  </tr>  <tr>    <td>Sphynx</td>    <td>Canada</td>  </tr>  <tr>    <td>Persian</td>    <td>Iran</td>  </tr></table>
```

```
cy.get('tr').eq(2).should('contain', 'Canada') //true
```

### Index From End

#### Find the 2nd from the last element within the elements

```
<ul>  <li>tabby</li>  <li>siamese</li>  <li>persian</li>  <li>sphynx</li>  <li>burmese</li></ul>
```

```
cy.get('li').eq(-2).should('contain', 'sphynx') // true
```

## Rules

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

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

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

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

## Command Log

**_Find the 4th `<li>` in the navigation_**

```
cy.get('.left-nav.nav').find('>li').eq(3)
```

The commands above will display in the Command Log as:

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

## See also

*   [`.first()`](/llm/markdown/api/commands/first.md)
*   [`.last()`](/llm/markdown/api/commands/last.md)
*   [`.next()`](/llm/markdown/api/commands/next.md)
*   [`.prev()`](/llm/markdown/api/commands/prev.md)
