:not()S2C Home « Selectors « :not()

Negation pseudo-class selector.

Shorthand version $(':not(selector)')


The :not() selector, selects all elements that do not match the given selector(s).

If this selector is not preceded by another selector, the universal selector ("*") is implied and so the whole DOM will be searched. Use another selector as in the example below to narrow the search and improve performance.


Signature Description
jQuery(':not(selector)')Negation pseudo-class match


Parameter Description
selectorValid selector(s) for filtering.



:not() ExampleTop

Selects all elements that do not match the given selector(s).

The following rather contrived example will check for input elements with an attribute of name that are not disabled (our input fields below) and set a message in them with a yellow background when the button below is clicked.

  $('#btn25').on('click', function() {
    $("input[name]:not(:disabled)").css('backgroundColor', 'yellow')
                                   .val("enter input"); 

Please fill in the form:

Your Information

 Enter your name:

Press the button below to action the above code: