Firstly the logic you have seems backwards to what you describe - you're hiding the p
element if there are multiple li
elements found, not if there are none. Secondly, closest()
looks at parent elements, where as the p
is a sibling of the div
, so you'd need to use prev()
instead. Try this:
$('.clients').each(function() {
var $ul = $(this);
if (!$('li', $ul).length) {
$ul.closest('.clients_wrap').prev('p').hide();
}
});