Trying to create an event to fire once a footer link has been clicked.
var hooray = function(event) {
console.log("hooray");
};
var footer_link = document.getElementsByClassName('footer-link');
console.log(footer_link);
footer_link.addEventListener('click', hooray, false);
<li class="footer-link">Title link
<ul class="footer-link-sub">
<li><a href="">link</a></li>
<li><a href="">link</a></li>
<li><a href="">link</a></li>
<li><a href="">link</a></li>
</ul>
</li>
I get an error of "Uncaught TypeError: footer_link.addEventListener is not a function". If the eventListener is taken out the console will log the correct li from the markup. Or if the element selector is removed from addEventListener it will fire whenever the page is clicked as expected. What am I doing wrong to select the element?