> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# SelectorQuery

APISummary
Gets a reference to the specified node in order to call its methods or get its properties.

Depending on the method of creation, each `SelectorQuery` object will be assigned a root node. The scope of any node search will be limited to the leaf nodes of that node.

## Instance Methods

[`SelectorQuery.exec()`](/next/api/lynx-api/selector-query/selector-query-exec.md)

Execute all submitted UI node operation tasks.

[`SelectorQuery.select()`](/next/api/lynx-api/selector-query/selector-query-select.md)

Select the first node that matches the specified CSS selector under the root node specified by `SelectorQuery`.

[`SelectorQuery.selectAll()`](/next/api/lynx-api/selector-query/selector-query-select-all.md)

Select all nodes that match the specified CSS selector under the root node specified by `SelectorQuery`.

[`SelectorQuery.selectRoot()`](/next/api/lynx-api/selector-query/selector-query-select-root.md)

Select the root node specified by `SelectorQuery`.

[`SelectorQuery.selectUniqueID()`](/next/api/lynx-api/selector-query/selector-query-select-unique-id.md)

Select nodes by specifying `uid`.

## Example

Get the position and size of the specified `text` node:

```tsx
class Page extends Component {
  componentDidMount() {
    lynx
      .createSelectorQuery() // create SelectorQuery
      .select('#my-id') // Specify the selector of the target node
      .invoke({
        // Specify the operation for the target node
        method: 'boundingClientRect',
        success: function (res) {
          console.log(res);
        },
        fail: function (res) {
          console.log(res.code, res.data);
        },
      })
      .exec(); // Execute the query
  }

  render() {
    return (
      <view>
        <text id="my-id">...</text>
      </view>
    );
  }
}
```

## Compatibility

**Compatibility Table**

**Query:** `lynx-api.selector-query.SelectorQuery`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/selector-query/SelectorQuery.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| SelectorQuery | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (3.7) | Yes (3.7) | Yes |
| &#96;exec&#96; | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (3.7) | Yes (3.7) | Yes |
| &#96;select&#96; | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (3.7) | Yes (3.7) | Yes |
| &#96;selectAll&#96; | Yes (2.8) | Yes (3.4) | Yes (2.8) | Yes (3.7) | Yes (3.7) | Yes |
| &#96;selectRoot&#96; | Yes (2.4) | Yes (3.4) | Yes (2.4) | Yes (3.7) | Yes (3.7) | Yes |
| &#96;selectUniqueID&#96; | Yes (2.3) | Yes (3.4) | Yes (2.3) | Yes (3.7) | Yes (3.7) | Yes |

**`SelectorQuery`**

Gets a reference to the specified node in order to call its methods or get its properties.

**`` `exec` ``**

Execute all submitted operations.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/selector-query/SelectorQuery.json) · [API Reference](/next/api/lynx-api/selector-query/selector-query-exec)

**`` `select` ``**

Select the first node that matches the specified selector in the descendants of the root node specified in `SelectorQuery`.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/selector-query/SelectorQuery.json) · [API Reference](/next/api/lynx-api/selector-query/selector-query-select)

**`` `selectAll` ``**

Select all nodes that match the specified CSS selector under the root node specified by `SelectorQuery`.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/selector-query/SelectorQuery.json) · [API Reference](/next/api/lynx-api/selector-query/selector-query-select-all)

**`` `selectRoot` ``**

Select the root node specified by `SelectorQuery`.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/selector-query/SelectorQuery.json) · [API Reference](/next/api/lynx-api/selector-query/selector-query-select-root)

**`` `selectUniqueID` ``**

Select nodes by specifying `uid`.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/selector-query/SelectorQuery.json) · [API Reference](/next/api/lynx-api/selector-query/selector-query-select-unique-id)

