title: How to set checked radio button using name and attr in jquery?
body: <p>I am working with some radio input and want to set them checked while edit function. I used ajax response. I have to set them checked.</p>
  
  <p>The code sample is following:</p>
  
  <pre><code>    &lt;form&gt;
  Group 1:
      &lt;input type="radio" name="ans1" str="ans_a" value="1" /&gt;
      &lt;input type="radio" name="ans1" str="ans_b" value="2" /&gt;
      &lt;input type="radio" name="ans1" str="ans_c" value="3" /&gt;
      &lt;input type="radio" name="ans1" str="ans_d" value="4" /&gt;
  
  Group 2:
      &lt;input type="radio" name="ans2" str="ans_a" value="1" /&gt;
      &lt;input type="radio" name="ans2" str="ans_b" value="2" /&gt;
      &lt;input type="radio" name="ans2" str="ans_c" value="3" /&gt;
      &lt;input type="radio" name="ans2" str="ans_d" value="4" /&gt;
  
  Group 3:
      &lt;input type="radio" name="ans3" str="ans_a" value="1" /&gt;
      &lt;input type="radio" name="ans3" str="ans_b" value="2" /&gt;
      &lt;input type="radio" name="ans3" str="ans_c" value="3" /&gt;
      &lt;input type="radio" name="ans3" str="ans_d" value="4" /&gt;
  
  
  &lt;/form&gt;
  </code></pre>
  
  <p>I get from ajax response the following:</p>
  
  <blockquote>
    <p>var ans_name = ans1,ans2,ans3;<br>
    var str = ans_c,ans_a,ans_d;</p>
  </blockquote>
  
  <p>That means i have to set checked the 3rd radio input of gruop 1 and so on.</p>
  
  <p>How can i set checked the corresponding radio button by jquery?</p>