How to get ID of button user just clicked? [duplicate]

$("button").click(function() {
    alert(this.id); // or alert($(this).attr('id'));
});

Leave a Comment