Having the following form:
<form id="my_form">
<input type="submit" value="Save" id="my_form_save"/>
<input type="submit" value="Save and apply" id="my_form_save_apply"/>
</form>
and the following jQuery code:
$('#my_form').submit(function(e) {
e.preventDefault();
var clicked_button = e.originalEvent.explicitOriginalTarget.id;
console.log(clicked_button)
});
I would like to know how to detect which of the two buttons were clicked.
The code above throws this error: Uncaught TypeError: Cannot read property 'id' of undefined.
Also, I found out that e.originalEvent.explicitOriginalTarget.id doesn't work on all browsers so I need another solution.