Data target from many parents to many childs

I have the following case:

https://gyazo.com/a73bdc5b049ac8d361a291c24be6334f

I have many parents, which has many childs. Right know the JS targets a parent, and that parent targets a specific child, but I have that for each one of them (so 12 functions), which is not... very well DRY and all of that.

I need somebody to help me really, to make it this way:

1) I click on Parent 1 and highlight it, this displays Child 1.
2) If I click again on said Parent, the Child will hide.
3) If I click on "x" inside said Child, it hides, and un-highlight's the Parent.

Right now, 3 doesn't happen, and 1 and 2 are just copy-pasted functions, all targeted to one ID specifically.

As I'm yet pretty noob with JS, I request help 😭
Gyazo
Gyazo
Was this page helpful?