---
title: viewer2d.select
slug: viewer-2d/events/viewer2d-select
docTags: 
createdAt: 2024-02-21T17:17:42.342Z
---

Invoked when the user changes the set of selected objects in the viewer.

## Example

::codepen{url="https://codepen.io/Catenda/embed/MWMBgeJ"}

## Usage

:::CodeblockTabs
```javascript
const onSelect = function (event) {
  const { selected } = event;
  console.log("viewer2d.select", "selected:", selected);
};

viewer2d.addEventListener("viewer2d.select", onSelect);
```

jQuery

```javascript
const onSelect = function (event, objectIds) {
  console.log("viewer2d.select", "objectIds:", objectIds);
};

$("#viewer-2d").on("viewer2d.select", onSelect);
```
:::

## Parameters

### onSelect

::::Tabs
:::Tab{title="JS"}
Function called when the user changes the set of selected objects in the scene.

| **Type**                  |
| ------------------------- |
| `(event: Object) => Void` |

**event**

| **Name**   | **Type**       | **Description**             |
| ---------- | -------------- | --------------------------- |
| `selected` | Array\[String] | List of selected object ids |
:::

:::Tab{title="jQuery"}
Function called when the user changes the set of selected objects in the viewer.

| **Type**                                            |
| --------------------------------------------------- |
| `(event: Object, objectIds: Array[String]) => Void` |

**event**

[jQuery.Event](https://api.jquery.com/category/events/event-object/)

**objectIds**

The ids of the selected objects.
:::
::::

