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:
<tr>
<td>Subtotal</td>
<td align="right">$189.00</td>
</tr>
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?
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:
<tr>
<td>Subtotal</td>
<td align="right">$189.00</td>
</tr>
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?
Share Improve this question edited Apr 1, 2015 at 19:22 Josh Crozier 241k56 gold badges400 silver badges313 bronze badges asked Apr 1, 2015 at 19:12 Doug FirDoug Fir 21.2k52 gold badges190 silver badges336 bronze badges 1- linked - stackoverflow.com/q/5684811/104380 – vsync Commented Oct 12, 2018 at 15:04
1 Answer
Reset to default 28You 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;