tags:

views:

371

answers:

2

I have some server side HTML output I cannot deal with using pure CSS, essentially the DIV sometimes holds:

<div><span>Content</span></div>

or

<div><p>Content</p></div>

or

<div>Content</div>

or

<div> </div>

When the DIV == <div> </div> I want to remove it.

Any ideas?

+5  A: 

I think you can do the following:

$(function() {
  $("div:empty").hide();
});

jQuery's empty pseudo selector is great.

Allain Lalonde
That's pretty cool, I didn't know about the empty pseudo selector
marcgg
+6  A: 

Even better (assuming jQuery):

$(document).ready(function() { $('div:empty').remove(); });

EDIT: The other answers are good, but the OP wanted to remove the empty item, not hide it.

Daniel Huckstep
+1 for that, it fits more what the OP asked for
marcgg
Credit where credits due lol
danit