jQuery - 如何选择没有类的元素?

发布于 2024-08-28 13:25:36 字数 329 浏览 5 评论 0原文

如何获取没有任何类名的元素?

        <td class="B A">A03<sub>reserved</sub></td>
        <td class="B R">R70</td>
        <td>105</td>
        <td class="M C">L220</td>

现在我正在这样做 $('td').not('.A, .B, .C, .M, .R')

一定有更好的方法!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不回头走下去 2024-09-04 13:25:36

您可以使用带有空白值的属性选择器:

$('[class=]')

You can use an attribute selector with a blank value:

$('[class=]')
挽梦忆笙歌 2024-09-04 13:25:36

这个怎么样:

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

不确定它是否适用于以下情况:

<td class="">

how about this:

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

not sure if it'll work for something like:

<td class="">
合久必婚 2024-09-04 13:25:36

一种方法是使用 filter()

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

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

$("td").filter( function() {return this.className=='';} )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文