ctrl+k
Enter a search term above to see results...
Loop through matched elements, transform values, and access underlying DOM elements.
$('selector').each(callback);Executes a function for each matched element. Inside the callback, this refers to the current DOM element.
| Name | Type | Description |
|---|---|---|
| callback | function | Function called with (element, index) for each element |
Query object (for chaining).
$('p').each((el, index) => { console.log(`Paragraph ${index}:`, el.textContent);});$('selector').map(callback);Creates a new array with the results of calling a function on every matched element.
| Name | Type | Description |
|---|---|---|
| callback | function | Function called with (element, index), returns a value |
Array of values returned by the callback.
const ids = $('button').map((el) => el.id);$('selector').filter(selector);$('selector').filter(fn);Reduces the set to elements matching the selector or passing the function test.
See also filter in DOM Traversal for selector-based filtering patterns.
| Name | Type | Description |
|---|---|---|
| selector | string | CSS selector to match |
| fn | function | Test function, return true to include |
Query object containing filtered elements.
$('p').filter('.highlight').css('background', 'yellow');$('div').filter((el) => $(el).css('display') !== 'none');$('selector').get();$('selector').get(index);Retrieves DOM elements from the Query object. Returns native DOM elements, not Query objects.
| Name | Type | Description |
|---|---|---|
| index | number | Index of element to retrieve (supports negative) |
undefined if out of rangeconst first = $('p').get(0);const last = $('p').get(-1);const elements = $('p').get();elements.forEach(el => console.log(el.textContent));