Getting class name of an element


I've a Symbol element with Class Name as "info1".
When I select it, I want to get its name so, I'd write something like:

var elementoClass = element.className;

but, when I select it the console shows:

elementoClass: HYPE_element HYPE_scene info1

Does anybody know how to solve this please?

var elementtoClass = element.classList[1]

'classList' contains all classes assigned to an element. Since classList[0] is always taken by 'HYPE_element' the first classname is contained in element.classList[1], the second in element.classList[2] and so on...

It does not work, because the console shows: HYPE_scene

Can you post your Hype file?

I've just changed to .classList[2] and it works!

1 Like

Hmmm, should be [1] anyway, if you assigned one classname to the element... (13.6 KB)

It is a symbol so it will also have the HYPE_scene class name, making it 3 class names in total with the user added class. [0-2]

1 Like

Ahhh, overlooked the symbol in the first post... :grinning: