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

# SelectorQuery: selectAll() method

APISummary
在 `SelectorQuery` 指定的根节点的后代中选择所有匹配指定选择器的节点。

## 语法

```ts
selectAll(selector: string): NodesRef;
```

### 参数

#### selector

用于匹配节点的 CSS 选择器组合。所有匹配指定选择器组合的节点将会返回。

用于匹配节点的 CSS 选择器必须满足指定语法，详见 [`select()` API 支持的 CSS 选择器语法](/next/zh/api/lynx-api/selector-query/selector-query-select.md#selector)。

### 返回值

代表该查询结果的 `NodesRef` 对象实例。

注意此时 `SelectorQuery` 只会将用户提供的查询参数保存在 `NodesRef` 对象中，并不会立即执行查询。
因此，通过以下方式查看节点信息或判断节点是否能够找到是**不可行**的：

```js
let nodesRef = lynx.createSelectorQuery().selectAll('#the-id');
console.log(nodesRef); // always returning a valid NodesRef object
```

## 注意事项

### 不要在 id 中使用数字、字母、横线和下划线以外的特殊字符

特殊字符可能会被解析为 CSS 选择器或组合器的一部分。

例如，`selectAll('#m.x')` 会被解析为查找同时具有 `id=m` 和 `class=x` 属性的元件，而不是查找 `id` 为 `m.x` 的元件。

## 兼容性

**Compatibility Table**

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

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| selectAll | Yes (2.8) | Yes (3.4) | Yes (2.8) | Yes (3.7) | Yes (3.7) | Yes |

**`selectAll`**

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

