:not() Selector

not selector

Description: Selects all elements that do not match the given selector.

  • version added: 1.0jQuery( ":not(selector)" )

    selector: A selector with which to filter by.

All selectors are accepted inside :not(), for example: :not(div a) and :not(div,a).

Additional Notes

The .not() method will end up providing you with more readable selections than pushing complex selectors or variables into a :not() selector filter. In most cases, it is a better choice.


Finds all inputs that are not checked and highlights the next sibling span. Notice there is no change when clicking the checkboxes since no click events have been linked.

<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <title>not demo</title>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
  <input type="checkbox" name="a">
  <input type="checkbox" name="b">
  <input type="checkbox" name="c" checked="checked">
$( "input:not(:checked) + span" ).css( "background-color", "yellow" );
$( "input").attr( "disabled", "disabled" );


© The jQuery Foundation and other contributors
Licensed under the MIT License.