Say I have these variables:
var container = $("div#my-awesome-section"); var foo_input = $("input[name=foo]", container); var bar_input = $("input[name=bar]", container); I want to bind an event handler to both inputs. I hoped this would work:
$([foo_input, bar_input]).on("keypress", function() { /* ... */ }); But alas, no. Is there a convenient way of gathering multiple jQuery objects into one for purposes like this?