开发者

jQuery - How to select elements that do NOT have a class?

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</t开发者_开发知识库d>
        <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!


You can use an attribute selector with a blank value:

$('[class=]')


how about this:

$("td:not([class])")

not sure if it'll work for something like:

<td class="">


One way to do it is to use filter():

$("td").filter( function() {return this.className=='';} )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜