javascript click event handler button of class remove code example
Example: an image gallery is a set of images with corresponding remove buttons
function setup() {
var els = document.getElementsByClassName("remove");
for (var i = 0; i < els.length; i++) {
els[i].addEventListener('click', function (e) {
e.preventDefault();
e.target.closest('div.image').remove();
});
}
}
setup();