Hello I do have following code sample in which Im trying to give each element different onClick functionality :
for (var i = 0; i < sizex; i++) {
for (var j = 0; j < sizey; j++) {
var canvas = document.createElement("CANVAS");
var id = i * 10 + j;
canvas.id = "canvas" + id;
canvas.width = 25;
canvas.height = 25;
canvas.style = "border:1px solid black";
canvas.onclick = function() {
canvasClicked(id);
};
document.body.appendChild(canvas);
}
}
problem is its always called with id = sizex * 10 + sizey
who can I pass parameter of canvasCliced to function so this function is "different" for each canvas?