I have a .submit()
event set up for form submission. I also have multiple forms on the page, but just one here for this example. I\'d like to know which submi
When the form is submitted:
document.activeElement
will give you the submit button that was clicked.
document.activeElement.getAttribute('value')
will give you that button's value.
Note that if the form is submitted by hitting the Enter key, then document.activeElement
will be whichever form input
that was focused at the time. If this wasn't a submit button then in this case it may be that there is no "button that was clicked."