Reputation: 3159
I am excluding first and last table row to calculate summary. Now added one more header with merging. So I need to skip second row as well. So I need to skip
first, second and last. I have added tr:not(:first,second, last) but It is not working. May I know how can I skip second row of table in this script.
Thanks,
$(".printer-type tr:not(:first, last) td:last-child").text(function() {
var totalVal = 0;
$(this).prevAll().each(function() {
totalVal += parseFloat($(this).children('.txtfld').val()) || 0;
//totalVal += parseInt( );
});
return parseFloat(totalVal).toFixed(1);
});
Upvotes: 0
Views: 2452
Reputation: 133453
You can use :lt(index)
Select all elements at an
index
less than index within the matched set.
$(".printer-type tr:not(:lt(2), :last) td:last-child")
:gt(index)
can also be used
Select all elements at an
index
greater than index within the matched set.
$(".printer-type tr:gt(1):not(:last) td:last-child")
Upvotes: 2
Reputation: 171698
Can use slice()
instead of selectors
$('.printer-type tr').slice(1,-1).children(':last-child')
Upvotes: 1