Get symbol id using javascript


I don’t seem to be able to get the id of a symbol using javascript with

Any ideas?

(strmiska) #2 (17,8 KB)


A bit more information on what I’m trying to do:

When a symbol instance is clicked by the user, I need to identify which instance was clicked. Each instance of the symbol has a unique id in my setup so I wanted to try and identify the instance that ran my JS function

(strmiska) #4

the elements inside a symbol gets unique IDs. you can call them by using standard-javascript:

var el = hypeDocument.getElementById("id");


So a symbol itself doesn’t get a unique id?

(strmiska) #6

you can give a symbol also an id like you give other elements in the inspector.
if you look into my example, the symbol gets one.


I’m trying to do the opposite of what you’re doing in your example (unless I’m completely missing something). You know the instance id and you’re getting the element. I don’t need the element, I need to get the id of the element (in my case the id of the symbol) that triggered some JS.

(strmiska) #8

the symbol id is called by symboInstances:

	var symbolInstance = hypeDocument.getSymbolInstanceById('mySymbolInstance');


Without seeing your document I don’t know exactly what it is you’re doing but if you want the element’s ID on click of that element then you can indeed use


this is a function run on Mouse Click with a symbol

work’s with all elements.

If you share a doc we can see what you’re trying to do :wink: