[jQuery] accesing array/variables with a function

[jQuery] accesing array/variables with a function


Hello
I'm having problems with the following code:
for (var i = 0; i < images.length; i++) {
var img = new Image();
        img.src = images[i][0];
$(img).bind('load', function() {
            stack.push( $('<a/>').attr('href', images[i][1]).append(this)[0] );
});
}
The problems seems to be because stack.push cannot access images[i][1]
which is a two-dimensional array, defined after/in $(document).ready
(function().
The error I get:
images[i] is undefined
[Break on this error] stack.push( $('<a/>').attr('href', images[i]
[1]).append(this)[0] );
event is not defined
[Break on this error] stack.push( $('<a/>').attr('href', images[i]
[1]).append(this)[0] );
If I replace images[i][1] with the value such as 'somelink.htm' it
will work just fine.
What am I doing wrong?
Thanks a lot for help!