1
是否可以通过jQ将CSS样式分配给一个语句中的多个选择器,就像它可以通过纯CSS完成的一样?通过jQuery将CSS应用于多个选择器
var foo = $('#thisEl');
var boo = $('#thatEl');
[foo and boo].css({
...CSS here
});
是否可以通过jQ将CSS样式分配给一个语句中的多个选择器,就像它可以通过纯CSS完成的一样?通过jQuery将CSS应用于多个选择器
var foo = $('#thisEl');
var boo = $('#thatEl');
[foo and boo].css({
...CSS here
});
您可以使用multiple selectors
$('#thisEl, #thatEl').css({
...CSS here
});
,或者如果你有jQuery的包装对象只引用然后使用.add()创建一个新的联合包装器的jQuery
var foo = $('#thisEl');
var boo = $('#thatEl');
foo.add(boo).css({
...CSS here
});
顺便说一句,会'foo.add(boo).add(goo).css({...'如果你想要3个或更多元素的工作? – user3024007
是。基本上任何你可以在CSS中使用的选择器,你也可以用作jQuery选择器。 – Jason