Javascript – Showing a div element dependent on if it has content


With jQuery I am trying to determine whether or not <div> has content in it or, if it does then I want do nothing, but if doesn't then I want to add display:none to it or .hide(). Below is what I have come up with,

if ($('#left-content:contains("")').length <= 0) {

This does not work at all, if the div has not content then it just shows up anyway, can any offer any advice?

Best Solution

Just use the :empty filter in your selectors.