[jquery] jQuery: how to get which button was clicked upon form submission?

This is the solution used by me and work very well:

_x000D_
_x000D_
// prevent enter key on some elements to prevent to submit the form_x000D_
function stopRKey(evt) {_x000D_
  evt = (evt) ? evt : ((event) ? event : null);_x000D_
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);_x000D_
  var alloved_enter_on_type = ['textarea'];_x000D_
  if ((evt.keyCode == 13) && ((node.id == "") || ($.inArray(node.type, alloved_enter_on_type) < 0))) {_x000D_
    return false;_x000D_
  }_x000D_
}_x000D_
_x000D_
$(document).ready(function() {_x000D_
  document.onkeypress = stopRKey;_x000D_
  // catch the id of submit button and store-it to the form_x000D_
  $("form").each(function() {_x000D_
    var that = $(this);_x000D_
_x000D_
    // define context and reference_x000D_
    /* for each of the submit-inputs - in each of the forms on_x000D_
    the page - assign click and keypress event */_x000D_
    $("input:submit,button", that).bind("click keypress", function(e) {_x000D_
      // store the id of the submit-input on it's enclosing form_x000D_
      that.data("callerid", this.id);_x000D_
    });_x000D_
  });_x000D_
_x000D_
  $("#form1").submit(function(e) {_x000D_
    var origin_id = $(e.target).data("callerid");_x000D_
    alert(origin_id);_x000D_
    e.preventDefault();_x000D_
_x000D_
  });_x000D_
});
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>_x000D_
<form id="form1" name="form1" action="" method="post">_x000D_
  <input type="text" name="text1" />_x000D_
  <input type="submit" id="button1" value="Submit1" name="button1" />_x000D_
  <button type="submit" id="button2" name="button2">_x000D_
    Submit2_x000D_
  </button>_x000D_
  <input type="submit" id="button3" value="Submit3" name="button3" />_x000D_
</form>
_x000D_
_x000D_
_x000D_