9951 explained code solutions for 126 technologies


jqueryHow do I use the jQuery not selector?


The jQuery not selector is used to select all elements that do not match a given selector. It is used to filter out certain elements that are not of interest.

Example

$('div:not(.myClass)').hide();

This code will hide all div elements that do not have the class "myClass".

The code consists of three parts:

  1. The jQuery selector, $('div:not(.myClass)') which selects all div elements that do not have the class "myClass".
  2. The jQuery action, hide() which hides the selected elements.
  3. The semicolon ; which marks the end of the statement.

For more information, see the jQuery not selector documentation.

Edit this code on GitHub