Even more simple, you can use precisely the same selector in jQuery as you could in CSS:
$('.element1, .element2').css('font-weight', 'bold);
Question
This is simply for keeping code neater. In CSS I can group elements like this:
.element1,
.element2,
.element3,
.element4,
.element5,
.element6 {
font-weight:bold;
}
is there anything similar in jQuery or would I have to set each separately.
$('.element1').css('font-weight', 'bold');
$('.element2').css('font-weight', 'bold');
$('.element3').css('font-weight', 'bold');
etc
I suppose I imagine something like
$('.element1', '.element2', etc).css('font-weight', 'bold);
Solution
Even more simple, you can use precisely the same selector in jQuery as you could in CSS:
$('.element1, .element2').css('font-weight', 'bold);
OTHER TIPS
The simple answer is yes, you can do that. But group your selectors using CSS syntax.
$('.element1, .element2, .element3').css('font-weight', 'bold');
$('.element1, .element2, etc').css('font-weight', 'bold');
Yes you can!
Except you want it like this: $('.element1,.element2').css('font-weight', 'bold);
Use multiple selectors. Example:
$("div,span,p.myClass").css("border","3px solid red");