简体   繁体   中英

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!

因为ul元素不包含除li元素之外的其他元素,所以这应该做你想要的:

$("ul:empty")

使用此代码

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM