I am assigning onclicks that contain the number that the link is on the page. This is my code:
var aTags = document.getElementsByTagName("a");
for (var t = 0; t < aTags.length; t++){
var aTag = aTags[t];
aTag.onclick = function(){setSubMenu(t);};
}
function setSubMenu(t){
console.log("t: " + t);
//The issue is t is always evaluating to the length of aTags
//instead of the current tag.
}
How do I fix this issue?