Is there a way to get the ID of a SVG element onClick?

image
I have a large SVG file with 100s of elements, I would like to do various activities based on user click on different components.

I am differentiating each element by a custom property named 'id'

But I am not sure how to access it to check which element is clicked.

In this above example,
I created a custom property 'id' on elements[1]['elements'][0] and assigned it a value 'something', How to find the user clicked on element 'something' ?

Only if you inject some js, i think it only works with "name" though not with "id" (so you should do name:"something"

1 Like