title: get the value of radio button groups using jquery
body: <p>I have a php loop code to generate radio button group</p>
  
  <pre><code>&lt;?php
  for($i=1; $i&lt;=10; $i++)
  {
  ?&gt;           
  &lt;div class="radio"&gt;
      &lt;label&gt;
          &lt;input name="ans_&lt;?php echo $i?&gt;" value="option2" type="radio"&gt;
          The smallest resistance
      &lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="radio"&gt;
      &lt;label&gt;
          &lt;input name="ans_&lt;?php echo $i?&gt;" value="option2" type="radio"&gt;
          The largest resistance
      &lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="radio"&gt;
      &lt;label&gt;
          &lt;input name="ans_&lt;?php echo $i?&gt;" value="option2" type="radio"&gt;
          They have the same power loss.
      &lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="radio"&gt;
      &lt;label&gt;
          &lt;input name="ans_&lt;?php echo $i?&gt;" value="option2" type="radio"&gt;
          Voltage and resistance values are needed.
      &lt;/label&gt;
  &lt;/div&gt;
  &lt;?php
  }
  ?&gt;
  &lt;button id="q_next" type="button" class="btn btn-warning pull-right savebtn" name="1"&gt;Save and Next&lt;/button&gt;
  </code></pre>
  
  <p>when we click on this button the name attribute value increases by 1 </p>
  
  <p>I am using this name attribute to make the name of the radio button. </p>
  
  <p>Now I want the jquery to get the value of selected radio of each group generated on the click of the button???</p>
  
  <p>I tried this but its not working </p>
  
  <pre><code>$('#q_next').click(function() { 
    $quesid=parseInt($(this).attr('name')); 
    $ans=$("input:[name='ans_'"+$quesid+"]").val(); 
  });
  </code></pre>