Hide div's if they are empty

后端 未结 10 1505
不思量自难忘°
不思量自难忘° 2020-12-03 07:21

I have some div\'s that maybe be empty (depending on server-side logic).

10条回答
  •  囚心锁ツ
    2020-12-03 08:08

    Why does nobody use .filter ?

    $("div.section").filter(function() {
        return this.childNodes.length === 0;
    }).hide();
    

    This is a more elegant solution compared to using .each.

提交回复
热议问题