---
id: api/commands/not
title: cy.not()
description: Filter DOM element(s) from a set of DOM elements in Cypress.
section: api
source_path: docs/api/commands/not.mdx
version: 29f95bf8bb06f320986f3749f5bf09a35a409eab
updated_at: '2026-09-04T10:49:54.630Z'
---
# not

Filter DOM element(s) from a set of DOM elements.

Opposite of [`.filter()`](/llm/markdown/api/commands/filter.md)

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

## Syntax

```
.not(selector)
.not(selector, options)
```

### Usage

**Correct Usage**

```
cy.get('input').not('.required') // Yield all inputs without class '.required'
```

**Incorrect Usage**

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

### Arguments

**selector _(String selector)_**

A selector used to remove matching DOM elements.

**options _(Object)_**

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

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

### Yields

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

## Examples

### Selector

#### Yield the elements that do not have class `active`

```
<ul>
  <li>Home</li>
  <li class="active">About</li>
  <li>Services</li>
  <li>Pricing</li>
  <li>Contact</li>
</ul>
```

```
cy.get('ul>li').not('.active').should('have.length', 4) // true
```

### Contains

#### Yield the elements that do not contain some text

There is no built-in negation for [`cy.contains()`](/llm/markdown/api/commands/contains.md), so there is no way to ask it directly for the elements that do _not_ contain a piece of text. Instead, select the full set of elements and remove the matching ones with [`.not()`](/llm/markdown/api/commands/not.md) and the [jQuery :contains](https://api.jquery.com/contains-selector/) selector. The match is a case-sensitive substring match.

```
<ul>
  <li>Test: Name</li>
  <li>Test: Name (1)</li>
  <li>Test: Name (2)</li>
  <li>Test: Name (3)</li>
</ul>
```

```
// yields only <li>Test: Name</li>, the item without a numeric suffix
cy.get('li').not(':contains("(")')
```

The same approach works with [`.filter()`](/llm/markdown/api/commands/filter.md) and the [:not()](https://api.jquery.com/not-selector/) selector when you would rather keep a positive filter:

```
// yields the rows that are not disabled
cy.get('tr').filter(':not(.disabled)')
```

## Rules

### Requirements

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

### Assertions

*   `.not()` 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).
*   `.not()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed.

### Timeouts

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

## Command Log

**_Find all buttons that are not of type submit_**

```
cy.get('form').find('button').not('[type="submit"]')
```

The commands above will display in the Command Log as:

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

## See also

*   [`cy.contains()`](/llm/markdown/api/commands/contains.md)
*   [`.filter()`](/llm/markdown/api/commands/filter.md)
