Reputation: 196
How would you do a similar function as rsplak's answer here https://stackoverflow.com/a/7079032/1330629 but include a defined variable in this? For example, I have a variable defined so that I'm not querying the DOM repeatedly, such as: var $StartDateTime = $("#StartDateTime");
and would like to include it with another selector, which I haven't defined as a variable.
Is this possible? I'm thinking along the lines of:
$($StartDateTime,link,#upload_link2,#upload_link3").each(function(){
$(this).upload({
//whateveryouwant
});
});
But obviously that's not going to work..
Upvotes: 0
Views: 186
Reputation: 1145
Either use add
as @gdoron suggested
var $combined = $StartDateTime.add('#newElement');
Or (IMHO producing a more elegant code) jQuery.merge
:
var $newElement = $('#newElement');
var $combined = $.merge($StartDateTime, $newElement);
Upvotes: 0