Example 1 — Official Demo: td:parent
Find table cells that contain text or elements (jQuery API example).
var $hits = $("td:parent");
console.log($hits.length);
console.log($hits.map(function () {
return this.textContent.trim() || "(empty text)";
}).get().join(", ")); How It Works
- Select all cells. Four
tdelements exist in the demo table. - Keep has-children.
:parentkeeps cells with a text child. - Drop empties. Truly empty cells have zero child nodes.

