title: How to undo a radio button selection using JavaScript or preferably jQuery
body: <p>I am working in a scenario with a group of radio button selections.
  The requirement is that only 2 can be selected Yes.
  So, if the third is also selected "Yes", I want to revert it to "No"</p>
  
  <p>Additionally I would also like to know if I can just check if a given index of Radio button within a group is checked instead of doing this:
  "($(this).is(':checked') &amp;&amp; $(this).val() == 'Y')"</p>
  
  <p>jsFiddle Link:  <a href="http://jsfiddle.net/pshah331/S8qep/" rel="nofollow">http://jsfiddle.net/pshah331/S8qep/</a></p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;p&gt;Folder A:
      &lt;input type="radio" name="folder_A" value="Y" onclick="folderSelectionChanged()" /&gt;Yes
      &lt;input type="radio" name="folder_A" value="N" onclick="folderSelectionChanged()" /&gt;No&lt;/p&gt;
  &lt;p&gt;Folder B:
      &lt;input type="radio" name="folder_B" value="Y" onclick="folderSelectionChanged()" /&gt;Yes
      &lt;input type="radio" name="folder_B" value="N" onclick="folderSelectionChanged()" /&gt;No&lt;/p&gt;
  &lt;p&gt;Folder C:
      &lt;input type="radio" name="folder_C" value="Y" onclick="folderSelectionChanged()" /&gt;Yes
      &lt;input type="radio" name="folder_C" value="N" onclick="folderSelectionChanged()" /&gt;No&lt;/p&gt;
  &lt;div id="update"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>JavaScript in "HEAD":</p>
  
  <pre><code>function folderSelectedYesCount() {
      var yesCount = 0;
      var folderRadioGroups = $("input[name^='folder_']");
  
  
      folderRadioGroups.each(function () {
          // TODO:  Would like to check by index --&gt; "index 0 is selected/checked"
          if ($(this).is(':checked') &amp;&amp; $(this).val() == 'Y') {
              yesCount++;
          }
      });
  
      return yesCount;
  }
  
  function folderSelectionChanged() {
      // TODO:  If count of Yes is greater than 2, then change the last clicked to "No"
      /*
      if (folderSelectedYesCount() &gt; 1){
          $(this)[1].prop('checked', true);
      }
      */
  
      $('#update').html('Selection count for "Yes" is &lt;b&gt;' + folderSelectedYesCount() + ' &lt;/b&gt;');
  }
  </code></pre>