tags:

views:

52

answers:

1
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');
+5  A: 

Use add():

var _sel3 = _sel1.add(_sel2);
David
okie i got it , i was not aware of the fact that we can pass some variable to ".add()" to add to current selection.it worked thanx.
Praveen Prasad
This is essentially the same as `$('.red').add('.yellow');`...
J-P