Reputation: 3068
How do I get elements that do not have any class names?
<td class="B A">A03<sub>reserved</sub></td>
<td class="B R">R70</td>
<td>105</td>
<td class="M C">L220</td>
Right now I'm doing this $('td').not('.A, .B, .C, .M, .R')
There's gotta be a better way!
Upvotes: 3
Views: 3721
Reputation: 37081
You can use an attribute selector with a blank value:
$('[class=]')
Upvotes: 12
Reputation: 338148
One way to do it is to use filter()
:
$("td").filter( function() {return this.className=='';} )
Upvotes: 0
Reputation: 6814
how about this:
$("td:not([class])")
not sure if it'll work for something like:
<td class="">
Upvotes: 7