假设我想在存储在变量中的特定表中导航。
我想在表的头上找到所有的输入。
如果我有桌子的身份证我就这么做-
$('#mytable thead tr input')但是假设我已经将表存储在一个变量中,并且我不再知道表的id - var mytableVar=$('#mytable')。
如果我还想导航到那个输入,我可以这样做-
$(mytableVar).children('thead').children('tr').children('input')是否有更短的方法来做到这一点,而不是必须在.children(...)上迭代
发布于 2014-02-14 13:53:07
您可以使用子选择器
mytableVar.find('> thead > tr > input')发布于 2014-02-14 13:52:51
要在$('#mytable thead tr input')中为表使用变量,可以这样做:
mytableVar.find('thead tr input')或
$('thead tr input', mytableVar)请注意,tr在那里很可能是无用的,所以只需使用
$('thead input', mytableVar)发布于 2014-02-14 13:53:28
是的,当然:
$(mytableVar).find('thead > tr > input')或者:
$(mytableVar).find('input')https://stackoverflow.com/questions/21781188
复制相似问题