I need to get the child's parent's ID
Heres what I Mean:
<div class="task" id="TheParent">
<img class="task-img" src="./index.png" />
<div class="Text-Container">
<p class="task-maintitle">Sample Task</p>
<p class="task-desc">Sample Desc</p>
</div>
<input type="checkbox" class="Check" id="check" onclick="Remove(this.id)" />
<!--Need this element's parent's id-->
</div>
I need to get it with this specifically because there are going to be many elements which are just duplicates.
Is there any way to get the parent's id?
You can get it with this.parentNode
I added this.parentNode.id for the demo purpose
function getParent(parenId) {
console.log(parenId)
}
<div id="parent-div">
<button onclick="getParent(this.parentNode.id)">
Test
</button>
</div>