I have a script that is supposed in an element with a default phrase if it is empty for a period of time. It works if i make a seperate if statement for every element but doesn't work when I try to combine it in one statement with $(this).
HTML
<div class="data-block">
<ul>
<li><h2>One</h2></li>
<li><h2></h2></li>
</ul>
</div>
<div class="data-block">
<ul>
<li><h2>Two</h2></li>
<li><h2></h2></li>
</ul>
</div>
<div class="data-block">
<ul>
<li><h2>Three</h2></li>
<li><h2></h2></li>
</ul>
</div>
Javascript
setTimeout(function() {
if ($.trim($(".datablock li:last-child h2").html()) == '') {
$(this).text('Not Applicable');
};
}, 1500);