On This Page
Query - Logical Operators
Logical operator methods in Query allow you to perform checks and filtering operations on sets of elements.
is
Checks the current matched set of elements against a selector, element, or Query object and returns true if at least one of these elements matches the given arguments.
Syntax
Parameters
Name | Type | Description |
---|---|---|
selector | String or Function | A string containing a selector expression to match elements against or a function to test each element |
Returns
boolean
- true
if at least one element matches, false
otherwise.
Usage
exists
Checks if there are any elements in the current Query object.
Syntax
Returns
boolean
- true
if the Query object contains at least one element, false
otherwise.
Usage
Quick Check -
exists()
is a convenient way to check for the presence of elements without needing to compare the length property.
not
Remove elements from the set of matched elements.
Syntax
Parameters
Name | Type | Description |
---|---|---|
selector | String or Function | A string containing a selector expression to match elements against or a function to test each element |
Returns
A new Query object with elements that do not match the selector.
Usage
Inverse Selection -
not()
is particularly useful for excluding specific elements from a larger set based on various criteria.