JSFiddle - React, Tailwind, and code Playground
HTML
<form name="edit_posting1" id="edit_posting1" method="post" action="edit_posting_bk.php" role="form">
<center>
<input class="btn btn-home" type="submit" name="publish" id="publish" alt="Publish" value="Preview" />
<input class="btn btn-home" type="submit" name="save" id="save" alt="Save" value="Save" />
</center>
</form>
JavaScript
$("#edit_posting1").on("submit", function(e) {
e.preventDefault();
var el = $(this).data('submitter');
alert(el);
});
$("#publish,#save").click(function(e) {
if (this.id == "save") {
if (!confirm('Are you sure you want to Submit.')) {
e.preventDefault();
return false;
}
}
$(this).closest("#edit_posting1").data("submitter", this.id);
});