The problem is your buttons are added after the page loads, so your normal addEventListener doesn’t see them. The solution is event delegation listen for clicks on the whole page and check if the clicked element is a delete button.
addEventListener