开发者

Jquery Select UL with no LI

开发者 https://www.devze.com 2023-02-20 05:57 出处:网络
I can select all ul elements that contain an li using: $(\'li:has(> ul)\') jQuery: determine if a <li> contains a 开发者_高级运维<ul>

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

精彩评论

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