I have 4 jQuery objects (i.e. things constructed via $("ObjectID")
), and I would like to perform the same operation to all of them, in an elegant fashion. I would have thought that something like these would work, but it doesn't seem to:
$([obj1, obj2, obj3, obj4]).change(function() { otherObj.show(); });
$([obj1, obj2, obj3, obj4]).attr("disabled", "disabled");
Is there a good syntax for this? It seems like a somewhat blinding oversight. Currently the best I'm seeing is
$([obj1, obj2, obj3, obj4]).each(
function() { this.change(function() { otherObj.show(); }));