Using querySelector() to obtain last td element

I have a variable which is a node from the dom. I’ve managed to get all the way down to close to where I want to be:

myvar.querySelector('.tblItinPriceSummary tr')

Gives me this:

  <td align="right">$189.00</td>

What I want is the textContent of the second td $189.

Is there anything I can add inside of querySelector so that I can append it with .textContent to get this piece of data?


You could either use :last-child or :last-of-type to access the last td element within the parent.

document.querySelector('.tblItinPriceSummary tr td:last-child').textContent;