# Catch annotation click even and select annotation programatically

**URL:** <https://pdfjs.community/t/catch-annotation-click-even-and-select-annotation-programatically/3265>\
**Category:** Technical Support\
**Created:** [May 9, 2024, 10:14am UTC](https://pdfjs.community/t/catch-annotation-click-even-and-select-annotation-programatically/3265 "2024-05-09T10:14:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vren369](https://avatars.discourse-cdn.com/v4/letter/v/a8b319/32.png) [@vren369](https://pdfjs.community/u/vren369)\
**Post date:** [May 9, 2024, 10:14am UTC](https://pdfjs.community/t/catch-annotation-click-even-and-select-annotation-programatically/3265/1 "2024-05-09T10:14:05Z")

</div>

**Which product are you using?**  
PDF.js Express Viewer or PDF.js Express Plus

**PDF.js Express Version**  
8.7.4

**Detailed description of issue**  
I am trying to select already drawn annotations programmatically with ID, I can pass the ID of annotation and based on it, that annotation need to be selected

Also when I select an annotation by clicking on it, I need to get the ID of it in my console

**Expected behaviour**  
I need to be able to store the annotation ID, and pass it to select annoation. On click of annotation I need to catch the id and print on console

**Does your issue happen with every document, or just one?**  
{Answer here}

**Link to document**  
{Provide a link to the document in question if possible}

**Code snippet**  
{Provide a relevant code snippet}

---

<div class="post-metadata">

**Author:** ![ejohnson](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@ejohnson](https://pdfjs.community/u/ejohnson)\
**Post date:** [May 9, 2024, 3:33pm UTC](https://pdfjs.community/t/catch-annotation-click-even-and-select-annotation-programatically/3265/2 "2024-05-09T15:33:32Z")

</div>

Thank you for posting your question to our forum. We will provide you with an update as soon as possible.

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [May 13, 2024, 6:39pm UTC](https://pdfjs.community/t/catch-annotation-click-even-and-select-annotation-programatically/3265/3 "2024-05-13T18:39:22Z")

</div>

Hello vren369

You can accomplish this by doing:

```javascript
instance.Core.annotationManager.addEventListener('annotationsSelected', (annotations)=> {
 console.log(annotations[0].Id)
})

```

Let me know if this works for you.

Best regards,  
Tyler
