JQuery not()
The not()
function in jQuery is used to exclude the elements specified by a selector from a selected set of elements.
Syntax
The basic syntax for using the not()
function in jQuery is as follows:
$(selector).not(excluded-selector);
In this syntax, selector
refers to the initial set of elements to be included, while excluded-selector
is the selector that specifies which elements to exclude from the selection.
Use
The not()
function is useful when you want to apply a specific action to a group of elements, but you want to exclude certain elements from that group. For example, you might want to apply a background color to all paragraph elements on a page, except for those within a specific section.
Example
Here is an example of using the not()
function to exclude certain elements from a selection: