views:

152

answers:

3

I have a list which is dynamically built, but there are empty list items which need removing.

<ul>
<li>www</li>
<li>www</li>
<li>www</li>
<li></li>
<li></li>
<li></li>
</ul>

How od i do this with jquery? Thanks

+2  A: 
$('ul li').filter(function() {return $(this).text()​​​​​​​ == '';}).remove();​
Max Shawabkeh
Thanks this worked a charm!
Mark
A: 
$('ul').find('li').each(function(){
    if($(this).is(':empty'))
        $(this).remove();
});

Please use Andy's implementation (above mine :))

Jarek
+4  A: 
$('ul li:empty').remove();

Kind Regards

--Andy

jAndy
heh, i did not hink o that, thanks :D +1
Jarek
+1: Nice. I wasn't aware of that one.
Max Shawabkeh