目前我正在使用
$('table').children('tfoot').children('tr').children('td');
获取tfoot中唯一的td。
我不喜欢使用 .children()
3 次,
有没有更好的办法?
编辑
轻微修正 选择器其实就是
var table = this;
$(table).children('tfoot').children('tr').children('td');
因为这是在 jquery 插件中。
最佳答案
$('table > tfoot > tr > td')
children()
在直系子女中搜索,所以为了复制这个,我使用了 direct descendant selector (>
)。
更新
根据您的更新,您可以...
$(table).find(' > tfoot > tr > td')
或者您可以将 table
替换为 this
。
很高兴你是thinking of the children .
关于javascript - 我需要一个更好的 jQuery 选择器来减少 children() 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4222270/