我试图让一个 div 显示另一个是否为空。这需要在整个页面中多次发生。该脚本在当前状态下无法运行。
脚本:
$('.standard_page_list_result').each(function(){
if ($('.children p').length == 0)
$('.summary').css("display", "block");
});
HTML:
<div class="standard_page_list_result"><div class="children"><p>Hello</p></div>
<div class="summary"><p>Goodbye</p></div></div>
<div class="standard_page_list_result"><div class="children"><p>Hello</p></div>
<div class="summary"><p>Goodbye</p></div></div>
<div class="standard_page_list_result"><div class="children"><p>Hello</p></div>
<div class="summary"><p>Goodbye</p></div></div>
<div class="standard_page_list_result"><div class="children"><p></p></div>
<div class="summary"><p>Hello!</p></div></div>
CSS:
.summary { display: none; }