Reputation: 27392
Using jQuery, how can I make it so that a function is called whenever any select object on the page is changed? All of my select inputs are added to the HTML by ajax functions.
Upvotes: 0
Views: 161
Reputation: 30442
As Y. Shoham says, it's the live
function that you are looking for. However, look closely at the documentation, change
is not supported in jQuery <= 1.3.2. Should be working as of jQuery 1.4.
And, yea, it should go without saying you can simply bind
to the change event of the new elements whenever you add them. This is obviously not ideal from a code-complexity stand-point but does work ok. Just remember not to rebind the ones that already exist (unless you unbind them all first -- a waste of cycles IMO).
Upvotes: 1