Selector problem: Empty UL inside LI
Hi *,
i just tumbled over a problem with my filetree. I guess it's a really basic, easy-to-solve problem but I don't know what to do
An example node from the filetree goes like this:
-
<ul>
<li>Node 1
<ul>
<li>Sub Node I
<ul></ul>
</li>
<li>Sub Node II
<ul></ul>
</li>
<li>Sub Node III
<ul></ul>
</li>
</ul>
</li>
</ul>
Unfortunately the empty ULs are "necessary" by code design (got it from a book).
Then I run the following jQuery against it:
-
$(document).ready(function()
{
$('li:has(ul)')
.click(function(event)
{
if(this == event.target)
{
if($(this).children().is(':hidden'))
{
$(this)
.css('list-style-image', 'url(images/minus.gif)')
.children().show();
}
else
{
$(this)
.css('list-style-image', 'url(images/plus.gif)')
.children().hide();
}
}
return false;
})
.css('cursor','pointer')
.click();
$('li:not(:has(ul))')
.css({
'cursor': 'pointer',
'list-style-image': 'none'
});
..............
});
How can I get rid of the
Sub Node children that have an empty UL in it?
I thought of something like
-
$('li:has(ul:empty)')
in an extra code block just before the
$('li:not(:has(ul))') but that didn't work out:
I checked the code in
http://www.woods.iki.fi/interactive-jquery-tester.html but the selector matches not only for the
Sub Nodes but also for the
Node (which has an UL with the
Sub Nodes in it and is therefore
not empty).
Does anyone of you jQuery cracks have an idea what the solution might be?
Thanks a lot in advance and best from sunny Berlin!
Fabian