---
name: "up.element.subtree"
area: "API"
kind: "JavaScript function"
parent: "up.element module"
url: "https://unpoly.com/api/up.element.subtree"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.element module](https://unpoly.com/api/up.element.md)</nav>

# up.element.subtree(root, selector)

Returns a list of a `root` element's descendants matching the given selector.

If the `root` element itself matches the selector, it is also included in the returned list.

---

## Parameters {#parameters}

### root {#root}

(required)

The root element for the search.

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)

### selector {#selector}

(required)

The CSS selector to match.

Type: string

---

## Return value {#return-value}

A list of all matching elements.

Type: [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList)<[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)>

