I just want to know if instead of
$(".element1").css('background','#000');
$(".element2").css('background','#000');
It is possible to concatinate multiple elements to have them affected by one command or if there is a more efficient way like so:
$(".element1",".element2").css('background','#000');
CSS selectors have always supported unions:
$(".element1, .element2").css('background','#000');
You can also add to the jQuery element set yourself:
$(".element1").add(".element2").css('background','#000');
All you needed was a cursory glance at the documentation.
$(".element1,.element2").css('background','#000');
will do
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With