[英]jQuery selector UL that contains NO LIs
Assuming the following HTML how can I find all uls that do NOT contain any lis? 假设使用以下HTML,如何查找不包含lis的所有ul? IE: In this case ul3 and ul4? IE:在这种情况下ul3和ul4?
I can see that jQuery has the "has" selector but I can't see the inverse of it? 我可以看到jQuery具有“具有”选择器,但看不到它的反函数吗? Nor do I understand how I could combine has and not to accomplish what I need. 我也不了解如何结合才能实现自己的目标。
<div id="div1">
<ul id='ul1'>
<li>
</li>
</ul>
<ul id='ul2'>
<li>
</li>
</ul>
<ul id='ul3'>
</ul>
<ul id='ul4'>
</ul>
</div>
Nor do I understand how I could combine has and not to accomplish what I need. 我也不了解如何结合才能实现自己的目标。
As far as I can tell, it's as simple as: 据我所知,它很简单:
$('ul:not(:has(li))')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.