I want to be able to hide a selector if it contains any data.
HTML
<ul>
<li></li>
<li>Test</li>
<li></li>
</ul>
JS
var x= $('#ul li');
if (x.html().length > 0) {
$(this).hide();
}
The $(this) isn’t working, but I have no idea how to select it.
You’ll want to iterate them using
.each(), then check the inner HTML of each element (that’s where$(this)makes sense in your case):