Hide div's if they are empty

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

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

10条回答
  •  渐次进展
    2020-12-03 08:20

    I used the filtering answer, but this.childNodes.length kept returning 1 also when there was no visible content, so ended up combining filter with trim.

    $("div").filter(function() {
        return j(this).text().trim() === "";
    }).hide();
    

提交回复
热议问题