JavaScript closures in for-loop
Posted
by
user1656447
on Stack Overflow
See other posts from Stack Overflow
or by user1656447
Published on 2012-09-09T21:34:16Z
Indexed on
2012/09/09
21:37 UTC
Read the original article
Hit count: 340
JavaScript
|for-loop
As explained here http://www.mennovanslooten.nl/blog/post/62/ code below outputs result just for "5x5" forgetting about anything before that.
for (x = 1; x <= 5; x++) {
for (y = 1; y <= 5; y++) {
var cords = x+"x"+y;
var el = document.getElementById(cords);
el.addEventListener("click", function (e) { B_modeWindow('1', cords); });
}
}
As far I have the informations (blog link provided above) can't figure out how to alter showed code to fix it.
How to walk around this code with JavaScript closure in my for-loop?
© Stack Overflow or respective owner