简体   繁体   English

jQuery选择一个具有某个类的div,它没有另一个类

[英]jQuery select a div with a certain class, that doesn't have another class

<div class="fuu">
  ...
</div>

<div class="fuu no">
  ...
</div>

...

How can I select all fuu 's besides the ones that have the .no class? 除了那些有.no类之外,我怎样才能选择所有的fuu

使用:not()排除其他类:

$('.fuu:not(.no)')

您还可以使用以下内容过滤掉'.no'类:

$('.fuu').not('.no');

获取div的类名,如果它在类名中有一个SPACE则表示它有多个类!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM