Possible Duplicate:
Remove Empty elements with jQuery
I want to remove empty <li> using jQuery. I am trying to do this but my code is not working as per my requirements. My code is show below.
Script
$(document).ready(function(e) {
$('#u li').each(function() {
if($(this).html(' ')) {
$(this).remove();
}
});
});
HTML
<ul id="u">
<li>hi</li>
<li></li>
</ul>
u, hence#u...#ulwouldn't match anything (you're thinking oful, but that would match every ul element instead of that particular one).