Having table
<table>
<tr><td></td><td class="foo"></td></tr>
<tr><td></td><td class="bar"></td></tr>
</table>
How to get all td elements having any class set?
While trying
$.each($("td:not(undefined)"),function(i,v){ ...
i still get undefined class in result
Try
The attribute selector selects elements with the given attribute see the docs.
As pimvdb pointed out
[class!='']will filter out elements which have no classes but has theclassattribute (i.e. an emptyclassattribute). Also, you can use.eachdirectly on a jQuery set.Also see the selectors specification.