Hello!
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?
Thanks!
ktewes
(Kalle)
May 13, 2022, 7:44am
2
Try
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...
ktewes:
.classList[1]
It does not work, because the console shows: HYPE_scene
ktewes
(Kalle)
May 13, 2022, 8:09am
4
Can you post your Hype file?
I've just changed to .classList[2] and it works!
thanks!
1 Like
ktewes
(Kalle)
May 13, 2022, 8:15am
6
Hmmm, should be [1] anyway, if you assigned one classname to the element...
classList.zip (13.6 KB)
MarkHunte
(Mark Hunte)
May 13, 2022, 12:57pm
7
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
ktewes
(Kalle)
May 13, 2022, 1:11pm
8
Ahhh, overlooked the symbol in the first post...
2 Likes