I needed to add an onclick event in a loop, so I searched and came across this: Setting onclick to use current value of variable in loop The problem with it, however, is that it always returns a mouse event. I did pretty much the exact same thing except with my own function, but it just returns a mouse event. I have no clue why and it doesn't make any sense to me. Here's the code:
var a=m.getElementsByTagName('topic');
for(var b=0,c=a.length;b<c;b++) a[b].onclick=function(a) {
return function(a) {
goToMB(a);
};
}(a[b].getAttribute('topicid'));