I have html elements like follows with unknown hierarchy:
<div class="parent" name="parent">
<div>
<div>
<div>
<div onclick="get_parent(this)">
Nested Child 1
</div>
</div>
</div>
</div>
</div>
<div class="parent" name="parent">
<div>
<div onclick="get_parent(this)">
Nested Child 2
</div>
</div>
</div>
Is there any easy way to get parent of nested child by class or name?
Maybe there is some alternative to child.parentElement
or child.parentNode
I am not aware of which may help me?
Or looping through all parents until I get needed class
or name
is the only possible choice?
.parents
)