JS: getting ID of button clicked in DOM

I've finally stopped avoiding learning how to use javascript and have been pretty successful lately... but I have run into something that I'm struggling to find the best answer for.

When working within the DOM, what is the best way to get the ID of a button clicked? There is a single button in a div, that are both created dynamically when a user clicks a button. Its relatively easy to delete the last div created; however, the user may want to delete the nTH one just as well.

The button is essentially a delete button for the div. I haven't bothered to fancy up the page, or even use a better mechanism for deleting, i'm just trying to figure things out. Any JS guys out here?

https://joe.raymundo.com/js/container

8 replies