This will return all div elements without text except spaces (or other characters removed by .trim , such as .trim characters):
var emptyDivs = $("div").filter(function() { return $.trim($(this).text()) === ""; });
Refresh - Based on Comments
If any of the div elements has child elements that do not contain text (for example, img ), then the above method will include them in the set of "empty" elements. To exclude them, you can use the following:
var emptyDivs = $("div").filter(function() { return $.trim($(this).text()) === "" && $(this).children().length === 0; });
James allardice
source share