0
I have two elements and would like to select the parent element using Javascript only, someone knows some way?
<tr>
    <td id="filho"><td>
</tr>
0
I have two elements and would like to select the parent element using Javascript only, someone knows some way?
<tr>
    <td id="filho"><td>
</tr>
7
Utilize parentNode:
Node.parentNode
var filho = document.getElementById("filho");
var pai = filho.parentNode;
console.log(pai);<div id="pai">
  Sou Pai
  <div id="filho">
    Sou filho do meu pai :D
  </div>
</div>1
Use the property parentNode
Ex:
document.getElementById('filho').parentNode
Browser other questions tagged javascript html
You are not signed in. Login or sign up in order to post.