var _sel1 = $('.red');
var _sel2 = $('.yellow');
How can I merge them into one, without using different selectors?
// I don't want to do it this way
var _sel3=$('.red,.yellow') or $('.red').add('.yellow');
Use add()
:
var _sel3 = _sel1.add(_sel2);