bind click-event via loop

bind click-event via loop

Hello,
I would like to substitute the following lines with a loop, such that I do not have to copy them countless times... (array stores jQuery-objects / with the $ in front)
  1. array[0].click(function() {    someFunction(0);    });
  2. array[1].click(function() {    someFunction(1);    });
  3. array[2].click(function() {    someFunction(2);    });
  4. ...
I tried:
  1. var imax = ...;
  2. for (var i = 0; i <= imax; i++) {
  3.         array[i].click(function(){
  4.              someFunction(i);
  5.         });
  6. }
and:
  1. for (var i = 0; i <= imax; i++) {
  2.         array[i].bind('click', function(){
  3.             someFunction(i);
  4.         });
  5. }
Both do not work.

Can someone please explain the reason for this (I'm guessing the assignment only 'lives' during execution of the loop-cycle) and maybe suggest a way around it?
Many Thanks.