我有三个相互嵌套的无序列表。第二个和第三个ul
被隐藏(display: none;
)
通过第一个事件,我需要显示第一个的所有ul.second
元素。li
ul.first
通过第二个事件,我需要显示第一个的所有ul.third
元素。这是代码:li
ul.second
HTML
<ul class="first">
<li class="first-element">
<ul class="second">
<li class="second-element">
<ul class="third">
<li class="third-element"></li>
<li class="third-element"></li>
<li class="third-element"></li>
</ul>
</li>
<li class="second-element">
<ul class="third">
<li class="third-element"></li>
<li class="third-element"></li>
<li class="third-element"></li>
</ul>
</li>
<li class="second-element">
<ul class="third">
<li class="third-element"></li>
<li class="third-element"></li>
<li class="third-element"></li>
</ul>
</li>
</ul>
</li>
<li class="first-element">
<ul class="second">
<li class="second-element">
<ul class="third">
<li class="third-element"></li>
<li class="third-element"></li>
<li class="third-element"></li>
</ul>
</li>
<li class="second-element">
<ul class="third">
<li class="third-element"></li>
<li class="third-element"></li>
<li class="third-element"></li>
</ul>
</li>
<li class="second-element">
<ul class="third">
<li class="third-element"></li>
<li class="third-element"></li>
<li class="third-element"></li>
</ul>
</li>
</ul>
</li>
</ul>
CSS
ul.second li {
display: none;
}
ul.third li {
display: none;
}
JS
$('li.first-element:eq(0) li.second-element').show(); // works fine, it shows only li.second-element of ul.first first li
$('li.second-element:eq(0) li.third-element').show(); // does not work, in log it gives me empty []
如何以li.second-element:eq(0) li.third-element
其他方式瞄准?