title: Getting data from radio button
body: <p>I'm trying to figure out how to check and write to the console if an option in a radio form is selected.
  I keep getting "Not checked", even if the right option is checked.
  Any ideas?
  I would prefer a solution that doesn;t include JQuery, since I study HTML and JavaScript.</p>
  
  <p>Thanks!!</p>
  
  <pre><code>&lt;body&gt;
  &lt;form id="office"&gt;
      &lt;label id="ques1"&gt; question 1&lt;/label&gt;&lt;br/&gt;
          &lt;div class="q1 wrong q1a1"&gt;&lt;input type="radio" name="question1"    value="q1a1" /&gt; Answer1 &lt;br/&gt;&lt;/div&gt;
          &lt;div class="q1 wrong q1a2"&gt;&lt;input type="radio" name="question1" value="q1a2" /&gt; Answer2 &lt;br/&gt;&lt;/div&gt;
          &lt;div class="q1 wrong q1a3"&gt;&lt;input type="radio" name="question1" value="q1a3" /&gt; Answer3 &lt;br/&gt;&lt;/div&gt;
          &lt;div class="q1 right q1a4"&gt;&lt;input type="radio" name="question1" value="q1a4" /&gt; Answer4 &lt;br/&gt;&lt;/div&gt;
  
              &lt;br/&gt;&lt;br/&gt;
  
       &lt;input type="submit" id="submit" name="submitAnswers" value="Submit Your Answers" onclick="checkFunction()" /&gt;
  
  
  &lt;/form&gt;
  
  
  &lt;script type="text/javascript"&gt;
  
  window.onload = function() {
  
   document.getElementById('submit').onclick = function() {
  if (document.querySelector('.q1 wrong q1a1').checked == true) {
    console.log('checked');
  } else {
    console.log('not checked');
  }
  };
  };
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>