Use strings in an array as jQuery selectors?

The follow jQuery code doesn’t work. Does that mean jQuery doesn’t support such a usage?


var selectors = ['#header', '#content', '#footer'];
$(selectors.join(',')).addClass("new");

I tested this code and it works, OP must had a problem somewhere else on the page.

Could you tell us how you solved it in case someone comes by this thread with the same question? :slight_smile:

Problem has been solved.