I have a form with the following:
<form id="my-form" ...> ... <button type="submit" name="bttnsubmit" value="1">The first button</button> <button type="submit" name="bttnsubmit" value="2">The last button</button> </form>
I would like to determine which one raised the form submit event using only:
$('#my-form').submit(function(){ //psuedo code if($('[name=bttnsubmit]').val() == 1) { .... } });
Obviously, the selector will always return the value of the first bttnsubmit element it encounters, so I need another magic selector or filter, or something like that.
I saw that $('[name=bttnsubmit][clicked=true]') advertised, but this still did not work in my attempts ...
I could, of course, resort to $('[name=bttnsubmit]').click() , but would rather be able to achieve my goals in the submit event.
Any help / advice is greatly appreciated.
jquery submit detect
Ian wood
source share