Reputation: 625485
I want every cell in each row except the last in each row. I tried:
$("table tr td:not(:last)")
but that seems to have given me every cell except the very last in the table. Not quite what I want.
I'm sure this is simple but I'm still wrapping my head around the selectors.
Upvotes: 8
Views: 10394
Reputation: 1182
fwiw I found your original works just fine (maybe an enhancement to main jQ since 2009?)...
$("#myTable thead th:not(:last)").css("border-right","1px solid white");
The header row of my table has navy background so the white border on the right made the table look snaggletoothed and not match the black 1px border of the data
Upvotes: 0
Reputation: 283
You could try
$("table td:not(:last-child)")
or
$("table td:not(:nth-child(n))")
where n is 1-based index of a child element
or
$("table td").not(":last-child")
Upvotes: 7
Reputation: 104196
Try the last-child selector. This:
$("table tr td:not(:last-child)")
will select all cells in all rows except of the cells in the last column.
Upvotes: 3