Add a dynamic function to an element using jQuery -


I am trying to work in a dynamic .change () list of elements:

  ELS = new array ('# element1', '# element2'); For (i = 1; i   

This does not work as desired because the i function has not been passed in, instead it is always equal to the last repetition, i.e. 2 How do I pass a value in change (function {}) ?

Two ways to do this $ $ Use each

  var element_array = new array ('# element1', '# element2'); $ .eu (element_array, function (index, value) {$ (value) .change (function () {alert (index);})}};   

Close one.

  var element_array = new array ('# element1', '# element2'); (I = 0; i & lt; element_array.length; i ++) {(function (i) {$ (element_array [i]) changes (function () {warning (i);});}) (I); }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -