63 of 119 menu

Method not

The not method excludes elements from a set based on a given selector.

Syntax

Excludes from the set those elements that match the selector:

.not(selector);

Filters a set of elements using the given function. This function is called separately, for each of the selected elements. If it returns true, then the current element will be excluded from the final result. The elements themselves are available in the function, in the variable this, and their ordinal numbers in the set — in the index variable.

.not(function(index, elem));

The parameter can also be a jQuery object:

.not(jQuery object);

Example

Let's find paragraphs that have classes not aaa or bbb and put '!!!' at the end of their text:

<p class='aaa'>text</p> <p class='bbb'>text</p> <p class='ccc'>text</p> <p class='ddd'>text</p> $('p').not('.aaa, .bbb').append('!!!');

HTML the code will look like this:

<p class='aaa'>text</p> <p class='bbb'>text</p> <p class='ccc'>text!!!</p> <p class='ddd'>text!!!</p>

See also

  • selector not,
    which excludes elements that match a given selector
  • method eq,
    which gets the element with a specific number
  • method first,
    which receives the first element
  • method last,
    which receives the last element
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