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/
精彩评论