I have this:
var $e1 = $('#e1');
var $e2 = $('#e2');
var $e3 = $('#e3');
This doesn't work:
var $all = [$e1, $e2, $e3];
$($all).css('background', '#ff0000');
How should I do this, while reusing $el1, $el2, $el3?
I don't want to do:
$('#e1, #e2, #e3')
This is probably very simple to do, but I don't know what to search for to find out.
$-prefix in variable names is for jQuery objects. Don't use it for regular arrays, it will only confuse you.[1, 2, 3]. This is a jQuery object:$('div'). When choosing a variable name, you use the $-prefix for those variables which values are jQuery objects. For instance:var x = true; var y = [1,2,3]; var $z = $('#z');