我有以下HTML结构:

<div class="s1>
 <div class="s2">
  <span class="span1">
    <span>text</span>
  </span>
 </div>
</div>


目前,我正在使用以下选择器选择嵌套最广的范围:

$(".s1").find(">:first-child").find(">first:child").find(">:first-child")


有没有一种更有效的方法来选择内部跨度?

编辑:类s1的Div已被缓存,所以我不能使用$(“ selector”)。

最佳答案

您可以通过span1类访问它,

$('.span1 span')

关于javascript - jQuery选择第一个 child 深入三个层次,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12693857/

10-12 12:30
查看更多