// To add an event listener in js, first grab the element and store in a var:
var todoUl = document.querySelector('ul');
// Then add the event listener to it:
todoUl.addEventListener('click', function(event){
// get the exact element that was clicked and make sure it was a <button> with classname of 'deleteButton'
var elementClicked = event.target;
if (elementClicked.className === 'deleteButton'){
handlers.deleteTodo(parseInt(elementClicked.parentNode.id));
}
}
//EVENT DELEGATION - this is called event delegation because we set up the event handler on the <ul> (which is the single common parent) on therefore only needed one event handler and then we wait for clicks on the delete buttons inside every <li>. This is better than having an event handler for every <li>.
//When using 'event' as an argument in the event listener you can use event.target.tagName to get the element you are looking for.