I'm looking to use JQuery to determine if a Div is empty without taking into account any content added before or after it. When checking for emptiness, I want to ignore anything placed before or after the div.
$(function(){
if($('#content').not(':empty')) {
console.log('Yes content');
} else {
console.log('No content');
}
});
#content:empty {
position: relative;
display: block;
min-height: 200px;
background-color: rgb(240,240,240);
text-align: center;
}
#content:empty:before {
content: 'NO IMAGE';
position: absolute;
font-size: 25px;
left: 0;
right: 0;
top: 50%;
transform: translateY(-50%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="content"></div>