我想隐藏哲学气泡 div,它的样式看起来像一个对话气泡,但如果内部 div 为空,则气泡将是一个需要隐藏的空对话气泡。我如何使用 jQuery 做到这一点?
<div class="philosophy-bubble">
<div id="ctl00_PlaceHolderMain_ctl00_ctl15__ControlWrapper_RichHtmlField" class="ms-rtestate-field" style="display:inline" aria-labelledby="ctl00_PlaceHolderMain_ctl00_ctl15_label">
<DIV id="ctl00_PlaceHolderMain_ctl00_ctl15_RichHtmlField_displayContent" class="ms-rtestate-write" EmptyPanelId="ctl00_PlaceHolderMain_ctl00_ctl15_RichHtmlField_EmptyHtmlPanel" style="display:;">
PROVIDING CARING AND KNOWLEDGABLE MEDICAL CARE TO PATIENTS
</DIV>
</div>
</div>
最佳答案
这应该对页面上的每个这样的 DIV 执行此操作:
$('.philosophy-bubble').each(function() {
var c = $(this).children().children(); // find the inner div
if (c.html().length == 0) { // check its content's length
$(this).hide();
}
});
关于jquery - 如果内部div为空,如何隐藏父div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8329348/