# Source: https://lynxjs.org/api/lynx-api/selector-query.md

# 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()`](/api/lynx-api/selector-query/selector-query-exec.md)

Execute all submitted UI node operation tasks.

[`SelectorQuery.select()`](/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()`](/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()`](/api/lynx-api/selector-query/selector-query-select-root.md)

Select the root node specified by `SelectorQuery`.

[`SelectorQuery.selectUniqueID()`](/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`

**Platform Support**

| Platform | Version Added | Notes |
|----------|---------------|-------|
| Android | 2.2 | - |
| iOS | 2.2 | - |
| HarmonyOS | 3.4 | - |
| Web | ✅ Yes | - |

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