Enter a search term above to see results...
On This Page
Query - Iterators
Iterator methods in Query allow you to loop through, manipulate, and filter sets of elements efficiently.
each
Iterates over a Query object, executing a function for each matched element.
Syntax
Parameters
Name | Type | Description |
---|---|---|
function | Function | Function to execute for each element |
Returns
Query object (for chaining).
Usage
Execution Context - Inside the callback,
this
refers to the current DOM element.
map
Creates a new array with the results of calling a provided function on every element in the set.
Syntax
Parameters
Name | Type | Description |
---|---|---|
function | Function | Function to execute for each element |
Returns
A new array with the results of the function calls.
Usage
Return Values - The
map()
method collects the return value of your callback function for each element into a new array.
filter
Creates a new Query object with all elements that pass the test implemented by the provided function.
Syntax
Parameters
Name | Type | Description |
---|---|---|
function | Function or String | Function or selector to test elements |
Returns
A new Query object with the filtered elements.
Usage
Flexible Filtering - You can pass either a function or a selector string to
filter()
. When using a function, returntrue
to include the element,false
to exclude it.