somehow my counter variable is not passed to the child function. i'm guessing it's because of some asyncronous behavior but actually i have no clue. please help.
$(document).ready(function() {
var imgArray = new Array();
$("canvas").each(function(i) {
imgArray[i] = new Image();
});
$.each(imgArray, function(i) {
alert(i);
//correct output
this.onload = function() {
alert(i);
//"undefined"
var width = this.width,
height = this.height;
var context = $("canvas")[i].getContext("2d");
//here's the error
/* more code */
};
this.src = "PATH";
});
});
so how can i pass the value for the right canvas?
thanks for any help!