The problem now is that in line 22 there is a conditional check that
calls twice the function targetInArray(target, array) defined in line
30. That function loops to check if the target is child of the container
or now. I don't think this is the proper way to do it because running
through loops every time there is a click would add much overhead.
Is there any better way to determine if the click has happened inside
the container or not? Or maybe a faster way to determine if the target
is somehow contained in that container. A way to determine a child/grand
child/grand grand child relationship maybe?