I often find myself doing things like this when manipulating tables:-
$($('table tr').children()[2]).html();
For when I want the cell in the 3rd column as a jQuery wrapped set. Selecting the node using [n]
and then passing to $()
to get a jQuery wrapped set.
Is there a neater more readable way to do this?
Use the .eq()
method
$('table tr').children().eq(2).html();
you could alternatively use the :eq
selector
$('table tr > :eq(2)').html();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With