简体   繁体   English

JQuery / CSS需要多个类

[英]JQuery/CSS require multiple classes

Is it possible in jQuery or CSS (since I think they use the same selector logic) to say select elements that have multiple classes. 是否有可能在jQuery或CSS(因为我认为他们使用相同的选择器逻辑)来说出具有多个类的select元素。 For example: 例如:

<div class='class1'></div>
<div class='class2'></div>
<div class='class1 class2'></div>

Is there a way I can say I want elements that are of both class1 and class2 (therefore only get the third div in this case)? 有没有办法我可以说我想要class1和class2的元素(因此在这种情况下只获得第三个div)?

The selector you are looking for is .class1.class2 您正在寻找的选择器是.class1.class2

For more info, check out the spec: http://www.w3.org/TR/CSS2/selector.html#class-html 有关详细信息,请查看规范: http//www.w3.org/TR/CSS2/selector.html#class-html

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

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