jquery 子元素选择器
循环最低级别“li”元素的正确方法是什么?
<div id="mainnav">
<ul>
<li>
<ul>
<!-- These are the elements I want to loop through -->
<li>
</li>
<li>
</li>
<li>
</li>
<!-- End These are the elements I want to loop through -->
</ul>
</li>
</ul>
</div>
我已经尝试过,但选择器没有触发。
jQuery("#mainNav > ul > li > ul > li").each(function () {
});
What is the correct method for looping through the lowest level "li" elements?
<div id="mainnav">
<ul>
<li>
<ul>
<!-- These are the elements I want to loop through -->
<li>
</li>
<li>
</li>
<li>
</li>
<!-- End These are the elements I want to loop through -->
</ul>
</li>
</ul>
</div>
I've tried this but the selector is not firing.
jQuery("#mainNav > ul > li > ul > li").each(function () {
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
#ID 选择器 区分大小写,您需要
#mainnav
(较低casen
),如下所示:您可以在此处进行测试。
#ID selectors are case sensitive, you need
#mainnav
(lower casen
), like this:You can test it out here.