jQuery .find(): Select Matching Descendants
jQuery .find() searches inside the elements you already selected and returns a new jQuery object containing matching descendants. It reaches direct children and elements nested further down. The starting elements stay out of the result even if they match the selector.
Find descendants inside a selection
The example’s #panel contains direct child a and nested descendant b. The panel itself and the outside paragraph c also have the .item class. Starting with $panel.find('.item') limits the matches to this panel even if the class is used elsewhere. See the official jQuery .find() documentation for the method signatures.
const $panel = $("#panel");
$panel.find(".item"); // a, b
$panel.find(document.getElementById("b")); // b
$panel.find($(".item")); // a, b
$panel.find("*"); // a, nested, b
Pass a selector string, a Document Object Model (DOM) element, or a jQuery object. Passing an element or collection keeps only those candidates that are descendants of the starting elements. Use '*' as the argument to find every descendant element. In this example, nested is the div surrounding b. In this example, the descendant selector $('#panel .item') returns the same two elements.
Compare the results of children, filter, and has
Choose the method based on which elements you need it to return. All four calls below start with the same $panel. The last column shows the IDs from the runnable example.
| Call | What it returns | Result IDs |
|---|---|---|
$panel.find('.item') |
Matching descendants at any depth | a, b |
$panel.children('.item') |
Matching direct children | a |
$panel.filter('.item') |
Elements in the current selection that match | panel |
$panel.has('.item') |
Elements in the current selection with a matching descendant | panel |
Use .children() documentation for one level, .filter() documentation to narrow the current selection, and .has() documentation to select the containers that hold matching descendants.
Run the example in a browser
Save the entire code as a UTF-8 file named jquery-find-example.html and open it in a browser. It loads the full jQuery 4.1.0 build from the official content delivery network (CDN) and needs an internet connection. The $(function () { ... }) callback runs when the document is ready.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Selection scope in jQuery .find()</title>
<script src="https://code.jquery.com/jquery-4.1.0.min.js"></script>
<style>
body { margin: 1rem; color: #21252a; background: #fff;
font: 1rem/1.5 system-ui, sans-serif; }
main { max-width: 38rem; margin-inline: auto; }
#panel, #nested { border: 1px solid #60727b; padding: .65rem; }
.item { margin-block: .55rem; padding: .35rem; }
.matched { background: #ffefb0; outline: 2px solid #704e00; }
dd { margin-inline-start: 1rem; }
</style>
</head>
<body>
<main>
<h1>Selection scope in jQuery .find()</h1>
<p><code>#panel</code> Panel where the search starts</p>
<div id="panel" class="item">
<p id="a" class="item">a Direct child</p>
<div id="nested">
<p id="b" class="item">b Nested descendant</p>
</div>
</div>
<p id="c" class="item">c Element outside the panel</p>
<h2>Result IDs by method</h2>
<dl>
<dt><code>.find(".item")</code></dt><dd id="found">—</dd>
<dt><code>.children(".item")</code></dt><dd id="children">—</dd>
<dt><code>.filter(".item")</code></dt><dd id="filtered">—</dd>
<dt><code>.has(".item")</code></dt><dd id="containing">—</dd>
</dl>
</main>
<script>
$(function () {
const $panel = $("#panel");
const $found = $panel.find(".item").addClass("matched");
function show(selector, $items) {
const ids = $items.get().map(element => element.id);
$(selector).text(ids.join(", "));
}
show("#found", $found);
show("#children", $panel.children(".item"));
show("#filtered", $panel.filter(".item"));
show("#containing", $panel.has(".item"));
});
</script>
</body>
</html>
Only a and b are highlighted, and the .find() output is a, b. .children() returns a. .filter() and .has() each return panel, for different reasons. Change the argument in $panel.find('.item') to '*' and reload to highlight nested too. Restore '.item' after checking.
Include the starting element or handle later descendants
To update the starting element and its descendants together, use $panel.find('.item').addBack('.item'). This adds matching elements from the previous selection, giving panel, a, b here. See .addBack() for details on how it combines the sets.
Adding a new item does not expand a saved jQuery result. Run $panel.find('.item') again after inserting the items. If the goal is to handle their clicks, use delegated events with .on() on a panel that remains in the DOM so later descendants can trigger the handler.
Diagnose an empty selection
Open the developer console while the example is running and enter the following code. It logs 1, 2, and 3 for the panel, matching descendants, and all descendant elements.
const $panel = $("#panel");
console.log($panel.length);
console.log($panel.find(".item").length);
console.log($panel.find("*").length);
If the first number is zero, check the starting selector and when the code runs. If the panel exists but the second number is zero, check which elements inside it have the requested class. A nonzero third number confirms there are descendants to inspect. If you see jQuery is not defined or $ is not defined, check the CDN request in the Network panel.




