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.
views:
93answers:
2
+1
A:
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).
thenduks
2009-12-29 23:23:30
It works in Chrome/Mozilla, but not IE. huh
Brian
2009-12-29 23:32:04
So you can use `bind` instead, and assign it any time you add new `select` s to the page. To avoid duplicate event calls, you can unbind+bind at each assignment.
Y. Shoham
2009-12-29 23:43:50