I'm trying to find the <a> tag that is clicked, save its href attribute to an array and print out array.
Problem: The array seems to be saving the values of hrefs, however it doesn't display it when i try to use a for loop. It only displays all the values inside array when the for loop is inside on click event handler (and i don't want to print for loop there). Ideas?
$(document).on('click', 'a', function () {
var url = $(this).attr('href')
hrefTracker.push(url);
});
for (var i = 0; i < hrefTracker.length; i++) {
console.log(hrefTracker[i]);
}