title: How can I check which of the two radio button is checked in javascript/jquery?
body: <p>How can I check which of the two radio button is checked in javascript/jquery in order to get the value of the input considering the fact that, in the HTML, both of them are by default unchecked (no <strong>checked</strong> attribute is added)</p>
  
  <pre><code>&lt;input type="radio" name="AS88" value="true" required&gt;
  &lt;input type="radio" name="AS88" value="false"&gt;
  </code></pre>
  
  <p>The following code does not work:</p>
  
  <pre><code>var elements = document.getElementsByName("AS88");
  for (var i=0, len=elements.length; i&lt;len; ++i) {
      if (elements[i].checked) {
          alert(elements[i].value)
      } 
  };
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Solutions with <code>:checked</code> in jquery such as:</p>
  
  <pre><code>$('input[name="AS88"]:checked').val();
  </code></pre>
  
  <p>always return <strong>undefined</strong></p>