I usually define all my jQuery variables at the top of the module I am working on. There sometimes becomes a case when I would like to combine the variables to effect them both. So for example, imagine a case where I have defined them like so:
$myVar = $('#my-var');
$myOtherVar = $('my-other-var');
If I want to remove them both from the DOM, I would have to do the following:
$myVar.remove();
$myOtherVar.remove();
Is there a way I could create another variable and combine them? So I wouldn't have to do this:
$('#my-var, #my-other-var).remove();
Thanks.
$myOtherVar.add($myVar).remove()