---
name: "SelectorQuery"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.10.0" }
title: "SelectorQuery"
---

## SelectorQuery

> [VERSION] Base Library >= 2.10.0

### Description

Object for querying node information. Create an instance via [ty.createSelectorQuery()](/en/miniapp/develop/miniapp/api/tyml/SelectorQuery/createSelectorQuery), used to query node layout, scroll position, etc., in a page or a custom component

### Parameters

None


### Return Value

Type: `SelectorQuery`

SelectorQuery instance

#### Methods

| Method | Description |
| --- | --- |
| `select` | Selects the first node on the current page that matches the selector. Returns a NodesRef instance that can be used to get node information |
| `selectAll` | Select all nodes matching the selector on the current page and return a NodesRef instance |
| `selectViewport` | Select the viewport; can be used to obtain the viewport's size, scroll position, and other information |
| `exec` | Execute all queued requests. The results are assembled into an array in request order and returned as the first argument of the callback |

### Examples

#### Create a SelectorQuery to query nodes

```js
Page({
  onReady() {
    ty.createSelectorQuery()
      .select('#my-id')
      .boundingClientRect((rect) => {
        console.log('Node info', rect);
      })
      .exec();
  },
});
```
