jQuery .find(): Select Matching Descendants

.find() searches the descendants of the currently selected elements. It searches through multiple nesting levels, but does not include the selected elements themselves.

Syntax and behavior

$("#panel").find(".item");
$("#panel").find("*");

Descendants include direct children and elements nested further below them. You can pass a selector, DOM element, or jQuery object. The selector form needs an argument; use "*" to find every descendant element. Use .children() for one level only and .filter() to narrow the current selection itself. A descendant selector such as $("#panel .item") can express the same search scope.

The official jQuery .find() documentation describes additional call signatures and argument types.

Complete runnable example

Save the following code as a UTF-8 example.html file and open it in a browser. It loads the full jQuery 4.0.0 build from an external URL, so an internet connection is required. The $(function () { ... }) callback waits for the document to be ready before running the example.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery find example</title>
  <style>
    body { margin: 24px; font-family: sans-serif; line-height: 1.6; }
    .marked { background: #fff0b3; border: 2px solid #835b00; }
    .active { color: #a00000; font-weight: bold; }
    button, input, select { font: inherit; }
    #output { white-space: pre-wrap; overflow-wrap: anywhere; }
  </style>
  <script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
</head>
<body>
<div id="panel" class="item">
  <p class="item" id="a">Direct child</p>
  <div><p class="item" id="b">Nested descendant</p></div>
</div>
<p class="item" id="c">Outside the panel</p>
  <p id="output" aria-live="polite"></p>
  <script>
    $(function () {
      const $items = $("#panel").find(".item");
      $items.addClass("marked");
      $("#output").text($items.map(function () { return this.id; }).get().join(", "));
    });
  </script>
</body>
</html>

Expected result

Only a and b are highlighted, and the output reads a, b. The panel itself and the outside paragraph c are excluded. Changing the argument to "*" also selects the nested div.

Important details and troubleshooting

  • Even if the container has the requested class, .find() excludes it. Use .addBack() or combine another selection when the container should also be included.
  • Elements that have not been created yet cannot be found. Query again after adding content, or use event delegation for handlers on future descendants.
  • If the result is empty, check the parent selection’s .length first. This separates an incorrect container selector from a descendant condition that does not match.

Compare the behavior with .addBack() and the traversal stack, .has() containing-element selection.