javascript - How do I gather multiple jQuery objects into one jQuery object? -


say 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 bind event handler both inputs. hoped work:

$([foo_input, bar_input]).on("keypress", function() { /* ... */ }); 

but alas, no. there convenient way of gathering multiple jquery objects 1 purposes this?

use in add() in jquery adding jquery object

foo_input.add(bar_input).on("keypress", function() { /* ... */ }); 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -