使用此 jquery 代码,我试图将显示从 none 更改为 block 下 Sale 下的第二个 ul,它位于 Belts 下(它有一个 belts-1 href)。下面的代码应该访问第二个元素,但不是。我究竟做错了什么?
$currentCategory = "Belts";
$(".sideCatMenu a:contains('" + currentCategory + "') ul").next(ul).eq(2).css('display', 'block');
我正在搜索这个列表
<li class="active"><a href="/sale/" class="parentSide">Sale</a><ul style="display: block;" class="subcat">
<li><a href="/accessories-3/">Accessories</a><ul style="display: none;">
<li><a href="/bags-1/">Bags</a></li>
<li><a href="/wristbands/">Wristbands</a></li>
<li><a href="/dog-collars/">Dog Collars</a></li>
<li><a href="/wallets/">Wallets</a></li>
</ul>
</li>
<li><a href="/ten-dollar-buckles/">Ten Dollar Buckles</a></li>
<li><a href="/belts-1/">Belts</a><ul style="display: none;">
<li><a href="/28-belts/">28" Belts</a></li>
<li><a href="/30-belts/">30" Belts</a></li>
<li><a href="/32-belts/">32" Belts</a></li>
<li><a href="/34-belts/">34" Belts</a></li>
<li><a href="/36-belts/">36" Belts</a></li>
<li><a href="/38-belts/">38" Belts</a></li>
<li><a href="/40-belts/">40" Belts</a></li>
<li><a href="/42-belts/">42" Belts</a></li>
<li><a href="/44-belts/">44" Belts</a></li>
<li><a href="/46-belts/">46" Belts</a></li>
<li><a href="/48-and-larger-belts/">48" and Larger Belts</a></li>
</ul>
</li>
</ul>
</li>