本文介绍了这两个选择器有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(this).parents('table:first > tbody > tr')
还有
$(this).parents('table:first').children('tbody').children('tr')
推荐答案
不同之处在于,第一个选择器完全在parents
调用之内,而第二个选择器则不在.
The difference is that the first selector is entirely within the parents
call, whereas the second one isn't.
因此,第一个查找与table:first > tbody > tr
匹配的所有this
父母. (换句话说,第一个table
中包含this
的tr
)
Therefore, the first one looks for all parents of this
which match table:first > tbody > tr
. (In other words, a tr
containing this
that is in the first table
)
第二个将找到与table:first
匹配的this
的父级,然后直接在该父级的tbody
内找到所有tr
. (换句话说,所有tr
都直接位于父表内部)
The second one will find the parent of this
which matches table:first
, then find all of the tr
s directly within tbody
s of that parent. (In other words, all of the tr
s directly inside the parent table)
这篇关于这两个选择器有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!