Reputation: 27
How can I select multiple fields in jQuery? (DOMs is an object)
clearFields: function() {
$(DOMs.inpDes, DOMs.inpVal).val("");
$(DOMs.inpDes).focus();
},
I use this
$(DOMs.inpDes, DOMs.inpVal).val("");
Upvotes: 1
Views: 210
Reputation: 350202
You can use the add
method:
$(DOMs.inpDes).add(DOMs.inpVal).val("");
If these object properties are CSS selector strings, like ".myclass", then you can also concatenate them, like this:
$([DOMs.inpDes, DOMs.inpVal].join()).val("");
... or like this:
$(DOMs.inpDes + "," + DOMs.inpVal).val("");
Upvotes: 1