开发者

Jquery Select UL with no LI

I can select all ul elements that contain an li using:

$('li:has(> ul)')

jQuery: determine if a <li> contains a 开发者_高级运维<ul>

Now, how can I select all ul that do not contain an li?

Cheers!


Use this code

$("ul:not(:has(li))")


As ul elments won't contain other elements than li elements, this should do what you want:

$("ul:empty")


This works - http://api.jquery.com/not-selector/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜