As in CSS , you can use a comma to separate multiple selectors :
$("#a, #b, #c, #d").click();
Note that this should not be the same selector. For example:
// Click the menu, all spans in all .foo, and paragraphs after headers $("#menu, div.foo span, h1 + p").click();
Also, if you already have jQuery objects, you can add()
such as:
var a = $('#a'), b = $('#b'), c = $('#c'); var all = a.add(b).add(c);
Phrogz
source share