I'm looping over multiple elements, which I'd like to assign an onclick event handler too.
The problem is that the element sent to the goTo function (event handler), is always the last element in the loop. What am I doing wrong?
var navLinks = document.getElementsByClassName('navigation');
for (var i = 0; i < navLinks.length; i++) {
var navLink = navLinks[i];
navLink.onclick = function() { goTo.call(navLink); }
}