How to use multiple jquery object variables as selectors?

You can use add :

jqId1.add(jqId2).show();

But don’t make your code too complex just to avoid querying "#id1,#id2" : this selector relies on getElementById and is very fast.

You can use each cycle:

$([jqId1, jqId2]).each( function(){
    $(this).show();
});

As answered here:
Select multiple jQuery objects with .add()

Leave a Comment