I have an array containing jquery objects which are later referenced in various parts of the code. I put them into an array so that they are only selected once, rather than doing a jquery select every time I need to access them.
My question is, how can I bind a jquery event to an array of these jquery objects?
I used to do a jquery select on the IDs of the elements and then bind the event:
$('#name, #domain, #description').bind("blur change",
function () {
callEventHandler(this);
});
Now I have this array of jQuery objects. How can I bind these to a jquery event?
var jqObjs = [$('#name'), $('#domain'), $('#description')];
I tried doing this, but it didn't work:
$(jqObjs).bind("blur change",
function () {
callEventHandler(this);
});