I'm having trouble getting the following code to pass JSHint
for (var i = 0; i < navLinks.length; i++) {
navLinks[i].addEventListener('click', loadPageContent);
}
function loadPageContent(e) {
e.preventDefault();
var pageURL = this.attributes.href.value; <-- Possible strict violation
loadContent(pageURL, function() {
var pageData = pages[pageURL.split('.')[0]];
// Create a new history item.
history.pushState(pageData, pageData.title, pageURL);
});
}
I know it's because "this" in a function declaration, but I don't know how to fix it, can anyone help? Thanks!