---
name: "SelectorQuery.select"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.10.0" }
title: "SelectorQuery.select - Select the first matching node"
---

## SelectorQuery.select

> [VERSION] Base Library >= 2.10.0

### Description

Selects the first node on the current page that matches the selector. Returns a NodesRef instance that can be used to get node information

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `selector` | `string` | Yes | Selector; supports ID selectors (#id) and class selectors (.class). |

### Return Value

Type: `NodesRef`

[NodesRef Object](/en/miniapp/develop/miniapp/api/tyml/NodesRef/NodesRef)

### Examples

#### Select a single node

```html
// index.tyml
<view id="my-id" class="box">Target node</view>
```

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

```css
// index.tyss
.box {
  width: 200rpx;
  height: 100rpx;
  background-color: #f0f0f0;
}
```
