Reputation: 85653
Suppose, I have multiple selectors used
$('.some, .next, .any, .way, .myname, .something')
and now if I would like to change each background when one background is changed, so I'm wondering how can I iterate all selectors using likely to this: $(this).each()
but I know this will not work coz this will take currently selected each elements but I would like to do all the selectors in my selectors used.
Upvotes: 3
Views: 69
Reputation: 382464
If you really need to do it :
var o = $('.some, .next, .any, .way, .myname, .something');
$.each(o.selector.split(/,\s*/), function(s){
var os = o.filter(s); // or $(s)
...
});
Not that this simple solution wouldn't work for any selector, a parsing would be needed if you really want to support them all (but it's probable you don't have commas in your elements id ;) ).
Upvotes: 3