Find the value of radio button checked in jquery
<p>I have this table containing 3 radio buttons, I want to find out whether a particular radio button is check or not at given point of time.</p>

<pre><code>&lt;table align="center" width="100%" border="0"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;
                &lt;input type="radio" name="compareRadio" value="all" checked="checked"/&gt;
                &lt;label&gt;View All Records&lt;/label&gt;
            &lt;/td&gt;
            &lt;td&gt;
                &lt;input type="radio" name="compareRadio" value="diff" /&gt;
                &lt;label&gt;View Differences&lt;/label&gt;
            &lt;/td&gt;
            &lt;td&gt;
                &lt;input type="radio" name="compareRadio" id="patch" value="patches" /&gt;
                &lt;label&gt;Compare Patches&lt;/label&gt;
            &lt;/td&gt;
            &lt;td&gt;
                &lt;input type="button" class="btn" value="Export Into Excel"/&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
</code></pre>

<p>I send a request to the server, when the result comes back I want to identify whether <code>patches</code> radio button is selected or not.</p>

<p>So I did something like this.. but it returns <code>all</code> radio button</p>

<pre><code>$.post("/csm/compare.action",
  { 
    sessiontoken: sessiontoken,
    compareCategory: "system",
    compareSubCategory:"patch",
    xml1:absP[0],
    xml2:absP[1]},
      function(resdata)
      {
        comparePatchData=resdata;
        comparePatchLoading=false;
        if($("input:radio[name=compareRadio]").val()=="patches")
        {
            //Trigger click on radio button for "same" campare
            $('input[name=compareRadio]:eq(2)').click();  //so that it refreshes the content
            $("input[name=compareRadio]:eq(2)").attr("checked", true);
            $('input[type="radio"]').removeAttr('disabled');
        }
      }
);
</code></pre>
