Can someone please tell me how can I grab i properly? By now, it's just displaying the same number (the value of a.length when clicking on any anchor element.
var a = document.getElementsByTagName('a');
for (i = 0, j = a.length; i< j;i++) {
a[i].onclick = function() {
console.log(i); //display a.length in all anchors
return false;
}
}