JQuery: select last row column selector
I have the following line in my table:
<tr><td>Adric cut-out</td><td><span class="quantity">0</span></td><td>worthless</td></tr>
I already got a range with the selected "count", but I am unable to get the last TD element in the selected row. I can do this by getting its parent, then its parent, then the last TD child, but is there something more efficient?
Using this as a start, how would you select the TD element that contains the price? Note that this will always be the last item on the line.
+3
source to share
3 answers
Take a look here: http://jsbin.com/odacar
What the last TD warns by using this:
function doAlert() {
alert($('td:last').html());
}
+2
source to share
You can use the last selector - http://api.jquery.com/last-selector/
$ ('tr') children ('td: last').
0
source to share