我想只遍历包含特定元素作为后代节点的父元素。通过包含特定后代节点的父元素遍历
例如:
<div class="field">
<input type="text" />
</div>
<div class="field">
<input type="button" />
</div>
<div class="field">
<input type="text" />
</div>
我知道,使用XPath,它可以通过使用div[@class = 'field' and input[@type = 'text']]
使用jQuery完成的,我想用类似的东西div.field[input[type = 'text']]
。
我知道最近的选项是div.field > input[type = 'text']
,但这种方式我会迭代输入而不是div。
在此先感谢
关于性能,'has'方法比'has'选择更快。 – undefined
这就是我正在寻找的答案!谢谢 – w35l3y