It's a small piece of code, but I can't get it to work. I have a menu which is filled dynamically with javascript, and I add an eventlistener on click for every button. Now every button needs a different function, so I loop through them
var list = $("a");
for (var i=0; i<list.length; i++) {
$(list[i]).on("click",function(){alert(i);});
}
With this code every button will give me an alert with 5, instead of 1,2,3,... How do I fix this?