如何使用jQuery选择所有空的p标签?

问题描述:

如何使用jQuery选择所有空标签.

How can I select all the empty tag using jQuery.

我要选择

<p></p>
<p style="display: block"></p>
<p> </p>
<p>     </p>
<p>&nbsp;</p>

不是

<p>0</p>
<p>Test</p>

尝试

var t = $('p').filter(function(){
    return $.trim($(this).text()).length == 0
});

演示:小提琴