if div has content show div
If you want to check for text, you can use the text()
method:
$(document).ready(function(){
if ($("#box3").text().length > 0) {
$('#third').show();
}
});
Or for html:
$(document).ready(function(){
if ($("#box3").html().length > 0) {
$('#third').show();
}
});
For the updated question: Check the trimmed text of the inner <div>
, like this:
if ($.trim($("#box3 div").html())) {
$('#third').show();
}
Previous answer: If you want to show if it has anything, then checking :not()
against :empty
works:
if ($("#box3:not(:empty)").length) {
$('#third').show();
}
If you want to check for any elements (not possibly whitespace only), then use :has(*)
, like this:
if ($("#box3:has(*)").length) {
$('#third').show();
}