我在同一问题上看到了一些帖子,但希望进一步澄清,因为我无法让这些答案中的任何一个起作用,特别是因为我无法从 Jquery 文档中选择答案。
我想组合一些类以方便级联适当的样式。我可以简单地在一个类中复制样式,但我认为那将是不好的做法。
<div class="left_Item drop_Down" id="col_1">some stuff</div>
$(".left_Item, .drop_Down#col_1").whatever....;
// matches every occurrence of class left_Item with the single occurrence of //drop_Down#col_1 ... this tallies with the multiple selector documentation.
$("#col_1").whatever....;
//obviously does match as the selector is only looking at the id.
//however
$(".drop_Down#col_1").whatever....;
//does not match Does this imply that the classes cannot be matched separately? So....
$(".left_Item.drop_Down#col_1").whatever....;
// various posts on so state that this should match it does not for me. Nor does
$(".left_Item .drop_Down#col_1").whatever....;
$(".left_Item").filter(".drop_Down#col_1).whatever....;
// various posts on so state that this should match also but it does not for me.
所以首先我假设我正在使用多个类做正确的事情。如果不是,我将停止尝试使这项工作!
其次,请有人给出正确的 jquery 语法来匹配具有多个类的元素。
谢谢