I was wondering whether there’s a way of using multiple selectors in jQuery and setting different values for them IN ONE CALL.
E.g.:
$(selector1, selector2, selector3, ...).css({left:[532, 112, 453, ...]});
Thanks in advance
Edited: Just to be clear you can only call .css once. Is it possible?
Edited again to clarify: I’m asking because if, for instance, I call animate()… I’d like to keep a unique synchronized call/loop.
Short answer, no you can’t do that, the selector and the methods you call aren’t connected like that. The selector gets you a set of elements, when that happens the
.css()(or any other) function doesn’t know what position the element you’re in was in the selector.If you think about it, it could be all positions, then what should it do?
For example:
What should this do on this HTML:
You see how it gets confusing real fast, so no, nothing like this is supported.
To be fair,
.css()does take a function, like this:But these elements are in the order they occur in the document, not related to the selector at all.