SyntaxFix
Write A Post
Hire A Developer
Questions
You could use event delegation on the parent div. Or use the closest method to find the parent of the button.
The easiest of the two is probably the closest.
var id = $("button").closest("div").prop("id");