Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The latest jQuery 1.4 supports 'live' for submit events now -- meaning you don't have to attach individual handlers to all your forms. A nice example that covers what you've asked is given by Paul Irish here:</p> <p><a href="http://jquery14.com/day-05/jquery-1-4-hawtness-1-with-paul-irish" rel="nofollow noreferrer">http://jquery14.com/day-05/jquery-1-4-hawtness-1-with-paul-irish</a></p> <p>Here's my own take:</p> <pre><code>jQuery(document).ready(function() { var pageForms = jQuery('form'); pageForms.find('input[type="submit"]').live('click', function(event) { var submitButton = this; var parentForm = jQuery(jQuery(this).parents('form')[0]); parentForm.data('submit-button',submitButton); }); pageForms.live('submit', function(event) { // Prevent form-submission. You can do this conditionally later, of course event.preventDefault(); // The form that was submitted var theForm = jQuery(this); // Detect which submit button was pushed var submitButton = theForm.data('submit-button'); console.log('submitButton = ',submitButton.value); }); }); </code></pre> <p>HTML:</p> <pre><code>&lt;form&gt; &lt;input type="submit" value="submit form 1" /&gt; &lt;/form&gt; &lt;form&gt; &lt;input type="submit" value="submit form 2" /&gt; &lt;input type="submit" value="submit form 3" /&gt; &lt;/form&gt; </code></pre> <p><a href="http://jsbin.com/equho3/6/edit" rel="nofollow noreferrer">http://jsbin.com/equho3/6/edit</a></p> <p>EDIT - Sorry, I posted an example here that matched the one in your link! I've now provided a cross-browser solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload