I can't access the variable from the marked point. The error console says the variable isn't declared. I've had the problem few years ago and I solved it, but I was googling for several hours and I can't find the solution anymore. Do you have an idea, what the problem is and how I can solve it?
Thanks in advance.
var smileys = [
[":smile:", "smile.png"],
[":sad:", "sad.png"],
[":love:", "love.png"],
[":angry:", "angry.png"],
[":amazed:", "amazed.png"],
[":laugh:", "laugh.png"],
[":wink:", "wink.png"],
[":crying:", "crying.png"],
];
$(document).ready(function(){
for(var i=0; i<smileys.length; i++){
var smiley = document.createElement("img");
smiley.src = "./res/" + smileys[i][1];
smiley.style.width = "24px";
smiley.style.height = "24px";
smiley.onclick = function(){
alert(smileys[i][0]);
// $("#chat-input").append(smileys[i][0]);
};
$("#smileys").append(smiley);
}
});