[ACCEPTED]-jQuery - How to select last column of all rows in a table?-jquery-selectors
:last
is a jQuery selector, but it will only 5 select the very last element of that type. You're most likely looking 4 for :last-child
.
Similarly, td:first-child
will get you the first 3 cell, while :first
gets you the first element 2 of that type.
Here's a Fiddle for you to look at 1 with all four examples.
As mentioned, to select every td
that is the 7 last child of its parent tr
, use :last-child
instead:
$('td:last-child')
The 6 reason why the :last
selector doesn't work is 5 because it actually gives you the last element 4 in the DOM that matches everything in the 3 selector up to the point where it occurs:
$('td:last')
returns the lasttd
element$('tr > td:last')
returns the lasttr > td
Since 2 every td
is tr > td
by necessity, there is no difference 1 in these two selectors.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.