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>