Determine which element submitted a form from within onsubmit
问题 Is there a way to determine which element submitted a form from within an onsubmit handler? Trying to write a generic handler that knows which element was clicked. For example, given this form: <form onsubmit="onSubmitHandler"> <input type="submit" name="submit1" /> <input type="submit" name="submit2" /> </form> How can I determine inside the onSubmitHandler which submit button was clicked? I tried event.target/event.srcElement, but that gives the form, not the actual submit button. Update: I