Getting the parent group id of Element

(Reza) #1

I have an element in a group. The group has an id and I wanted to use Javascript to be able to get the id of group from the containing element.

Get Parent ID Name
(Mark Hunte) #2

To be honest a little more info would help. but here is an answer on assumption that you mean


There are a few ways this can be done… here is one.

	var _containers = hypeDocument.getElementById(hypeDocument.documentId()).querySelectorAll('.HYPE_element_container')

for (i = 0; i < _containers.length; i++) { 
 var _children = _containers[i].childNodes 
			for (i = 0; i < _children.length; i++) { 
 					console.log(_children[i].id );

(Reza) #3

Thanks for that.
Yes I did mean grouping of elements in the list view of elements which I guess is HYPE_element_container.
I was trying to avoid having to go through all the elements every time I need to check for this,

(Mark Hunte) #4

A bit more info on what your goal is and what you know at the time of trying to access the group id may help in a better answer.

maybe an example project to help explain the set up and goal…

(Reza) #5

I have attached a sample project. Tapping on any of the red buttons I would want to know what group they belong to. (25.3 KB)

(Mark Hunte) #6

one of the simplest ways I think is


The buttons are in a container (DIV) each inside the group.

This is why we use parentElement twice.

As illustrated with this version.