javascript - Hide parent li element if the child span element is empty -
i want build jquery supported way hide (li) parent element if child (span) element empty. build such question have no idea why isn´t working.
<li data-column="3" class=„parent“> <span class=„childtitle">lorem ipsum</span>: <span class="childvalue"><!—child value--><!—child value--></span> </li>
i tried build if question:
$( document ).ready(function() { if ($('span.childvalue').is(':empty')){ $(this).parents().hide(); } });
i tried build simple function:
$("span.childvalue:empty").parent().hide();
but either dosn´t work. finished code shall build in wordpress child theme javascript. tried different ways none of had result.
once fix weird quotes in example code can use this:
$('span.childvalue').each(function() { if ($(this).is(':empty')) $(this).parent().hide(); })
note want use parent()
, not parents()
hide <li>
Comments
Post a Comment