How do I use jQuery to check to see if the content of a <div>
is empty?
I tried this and is doesn't seem to be printing the correct values.
...
var unframed_items = $("#unframed-items");
alert(unframed_items.html().length);
...
<div id="unframed-items"> </div>
...
Use
$('#elementId').is(':empty')
.If you mean really empty, use the
empty-selector
[docs] :or
If you consider whitespace-only to be empty, then use the
jQuery.trim()
[docs] method: