Reputation: 10571
I am able to get td's last child using this
$jq('#stripeTable > tbody > tr:nth-child('+(i+1)+') >td:last-child').text(colValues +" < "+ colValuesWithOverTime);
what to do and get second last child of td like i am getting last child using td:last-child
Upvotes: 2
Views: 3244
Reputation: 28564
console.log($("td").last().prev().text());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
use last and prev,
$("td").last().prev();
Upvotes: 1
Reputation: 101
Try td:nth-last-child(2). This will select the 2nd child from the end.
Upvotes: 5
Reputation: 2228
Use .eq()
function to get second last from jQuery array
var count = $('td').length;
var secondLast = $('td').eq(count - 2);
Upvotes: 0