I am not sure if "concatenate" is the correct term for it, but something like this:
$("#a").$("#b").$("#c").$("#d").click(); // click on all of them
Basically I have a long list of stuff but I can't apply a class to them.
You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order.
So far we have covered only three standard jQuery Selectors.
The .append() method inserts the specified content as the last child of each element in the jQuery collection (To insert it as the first child, use .prepend() ). The .append() and .appendTo() methods perform the same task. The major difference is in the syntax-specifically, in the placement of the content and target.
As in CSS, you can use a comma to separate multiple selectors:
$("#a, #b, #c, #d").click();
Note that these do not have to be the same kind of 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 the jQuery objects, you can add()
the sets like so:
var a = $('#a'), b = $('#b'), c = $('#c');
var all = a.add(b).add(c);
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