Although plalx's answer may work, it's delicate, but it's perfectly possible to have this:
<td class=""></td>
...which would match his selector. And in fact, it's quite common, particularly if you started out with a class on the cell but then removed it with removeClass
or toggleClass
.
To be sure, you do this:
var countWithNoClasses = $("#mytable td").filter(function() {
return $.trim(this.className) === "";
}).length;