Get selected form data using jQuery : <p>I have a scenario where a page have multiple forms and I am trying to get the form data which is being submitted.</p>

<p>HTML</p>

<pre><code>&lt;form name="form1"&gt;
    &lt;input type="text"&gt;
    &lt;input type="button" value="Submit"&gt;
&lt;form&gt;
&lt;form name="form2"&gt;
    &lt;input type="text"&gt;
    &lt;input type="button" value="Submit"&gt;
&lt;form&gt;
</code></pre>

<p>jQuery</p>

<pre><code>$('[type="button"]').click(function(e){
    e.preventDefault();
    console.log($(this).parent().attr('name'));
});
</code></pre>

<p>I always get form1 in console. I also tried <code>jQuery('form')</code> in console and it is also returning only the first form. I don't know what I am doing wrong or it is browser feature.</p>
