<div class="parent">
<div class="child_1">
content to remove if child_2 is empty!
</div>
<div class="child_2">
content of child_2
</div>
在页面中重复了十几次..我如何检查是否有任何“child_2”元素为空,如果是,则删除“child_1”的内容??
谢谢
卢卡
最佳答案
$('div.child_2:empty').each(function() {
$(this).prev('div.child_1').empty();
});
关于jquery循环检查元素是否为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5381476/