Determining index of array input that has changed


I have a set of array indexed input fields i.e. field[0], field[1] etc.

I have a change event handler associated to them using jquery:

$("[id^=field]").change(function() {
// code here

I was wondering if there’s a simple way I could determine the index of the field input that has been changed.


For what purpose?

The data set sent via AJAX will consist of the value of the indexed field that has changed, as well as the value of a number of other fields of the same index.

It should be possible to use $.makeArray() to convert a selection in to an array, and [url=“”]$.inArray() to find the location of an element within that array.

Thanks for that. I’ll try it out!