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

# NodesRef: invoke() method

APISummary
Execute the UI method of the selected node.

Please note that the UI function is a function provided by the client, usually directly controlling UI functions, such as the play or stop of the player.
`invoke` cannot be used to call a js function of a custom component.

## Syntax

```ts
invoke(options: Record<string, any>): SelectorQuery;
```

### Parameters

### options

The `options` parameter is a `Record<string, any>`, which contains the information needed for the execution of the UI method. Its key list is as follows:

- `method`

- A `string`, the name of the UI method to be called

- `params` (optional)

- A `Record<string, any>`, the parameters of the UI method to be called

- `success` (optional)

- A callback function that is called when the UI method is successfully executed, with the first parameter being the result returned by the UI method

- `fail` (optional)

- A callback function that is called when the UI method fails to execute, with the first parameter type being `{code: number, data: any}`, which contains the error code and error message returned by the UI method.

- If no fail callback function is provided, a red screen error will be generated when the UI method fails to execute.

### Return Value

Contains the `SelectorQuery` object for this task. Call `exec()` to execute the task.

## Examples

```javascript
var params = {
  method: 'seekTo',
  params: {
    duration: 1000,
  },
  success: function (res) {
    console.log(res);
  },
  fail: function (data) {
    console.log(data.code, data.data);
  },
};

lynx.createSelectorQuery().select('#video').invoke(params).exec();
```

## Compatibility

**Compatibility Table**

**Query:** `lynx-api.nodes-ref.invoke`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/nodes-ref/invoke.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| invoke | Partial (2.2) | Partial (3.4) | Partial (2.2) | Partial (3.7) | Partial (3.7) | Partial |

**`invoke`**

Execute the UI method of the selected node.

- **Android — From 2.2:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **HarmonyOS — From 3.4:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **iOS — From 2.2:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **macOS — From 3.7:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **Windows — From 3.7:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **Web — Supported (version unknown):** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.prototype.selectAll()`.

