Currently I am using
$('table').children('tfoot').children('tr').children('td');
to get the only td in the tfoot.
I dont like using .children()
3 times,
Is there a better way?
Edit Slight correction The selector is actually
var table = this;
$(table).ch开发者_如何学Goildren('tfoot').children('tr').children('td');
as this is inside a jquery plugin.
$('table > tfoot > tr > td')
children()
searches in immediate children, so to replicate this, I used the direct descendant selector (>
).
Update
From your update, you could do...
$(table).find(' > tfoot > tr > td')
or you could replace table
with this
.
I'm glad you are thinking of the children.
$('table>tfoot td');
You better to read about CSS-style selectors.
And for updated version:
$('tfoot>td',this);
精彩评论