Q:

jQuery multiple selectors same function

I have this jQuery Code:
$('#select-adults-room-1').change( function () {
  og.removeErrorsOcio();
});
$('#select-kids-room-1').change( function () {
  og.removeErrorsOcio();
});

What is the best way to do it? I know this looks weird, but not sure how to improve it if it's possible.
I'm looking for some like this:
$('#select-adults-room-1','#select-kids-room-1').change( function () {
  og.removeErrorsOcio();
});

Thanks

A:

You don't need to pass separate strings, place the comma between the selectors in a single string, like this:
$('#select-adults-room-1, #select-kids-room-1').change(function() {
    og.removeErrorsOcio();
});

Also note that you can pass the reference of the function directly to the change() method, like this:
$('#select-adults-room-1, #select-kids-room-1').change(og.removeErrorsOcio);

