75 of 119 menu

Selector not

The :not selector selects those elements that do not match the given selector. In most cases, to make the code more readable, it is recommended to use the not method.

Syntax

This is how we select elements:

$(':not(selector)');

Example

Let's select only those paragraphs that don't have the class www at the end of the text '!!!':

<p class="www">text</p> <p class="zzz">text</p> <p class="www">text</p> <p>text</p> $('p:not(.www)').append('!!!');

HTML the code will look like this:

<p class="www">text</p> <p class="zzz">text!!!</p> <p class="www">text</p> <p>text!!!</p>

See also

  • method not,
    which excludes elements from a set based on a given selector
  • method filter,
    which filters elements in a set by a given selector
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline